個人が作成したコメントをテーブルから選択する必要があるアプリケーションに取り組んでいます..しかし、結果セットからデータを取得する際に問題があります..これは私のSQLステートメントです.
public function get_Comments()
{
$select=$this->_db->select()
->from('comments',array('id','comment','user_id'));
$result=$this->getAdapter()->fetchAll($select);
return $result;
}
コントローラーでデータを受け取り、この方法でアクションを実行しました.. $comments=new Application_Model_DbTable_Procedure(); $main_comments=$comments->get_Comments();
$result=(array) $main_comments;
print_r($result);
私はまだデータをビューに持っていませんが、コントローラーから直接表示して後で移動したかっただけです..これは私が得る配列です
Array ( [0] => Array ( [id] => 1 [comment] => how is attachment in safaricom [user_id] => 2 ) [1] => Array ( [id] => 2 [comment] => hello world [user_id] => 2 ) [2] => Array ( [id] => 3 [comment] => how is attahment in kra [user_id] => 2 ) [3] => Array ( [id] => 16 [comment] => how is attachment in kra? [user_id] => 3 ) [4] => Array ( [id] => 17 [comment] => hello world [user_id] => 2 ) [5] => Array ( [id] => 18 [comment] => this is me trying everythin out [user_id] => 2 ) [6] => Array ( [id] => 19 [comment] => am testing system [user_id] => 3 ) )
I wanted to get the result in three columns:
id comment user_id
foreach ループを使用してみましたが、結果が得られません.... zend は初めてです... このサイトで解決策を確認しようとしましたが、問題を解決するものは得られません。