0

最初と 2 番目のテーブルからフィールドを選択する zf2 を使用して単純な結合を実行したいのですが、フィールドの配列を列メソッドに入れようとするとエラー (「ステートメントを実行できませんでした」) が発生します。

public function fetchAll()
{
    $resultSet = $this->tableGateway->select(function (Select $select) {
        $select->columns();// ->with params gives an 'Statement could not be executed'
        $select->join(array('t2' => 'categories'), 'table1.idCategory = t2.id');
        $select->order('dateTime DESC')->limit(100);
    });  
...
}
4

2 に答える 2

0

You will need to make sure the dateTime/id fields are in the column list you provide.

If you dump out the exception ($e->getTraceAsString()) you will get some more information about what is causing your error.

于 2013-02-08T09:31:51.350 に答える
0

このステートメントをコメント化する、少なくとも 1 つの有効な「列」名を配列 (テーブルの列/フィールド名) に追加します。

$select->columns(array('column_one', 'column_two', 'column_N'));

空白の$select->columns();ステートメントは、エラーになるような SQL クエリを生成SELECT FROM table_nameします。

このステートメントにコメントをSELECT * FROM table_name 付けると、次のようなSQLクエリが生成され、列名を渡すと、アスタリスクがそれらに置き換えられます。

于 2013-04-19T10:11:48.313 に答える