2011-01-09 22 views
1

私はsymfony を使用してクラスを生成し、生成されたフォームクラスを使用してオブジェクトのペアを作成しました。基準: "未定義オフセット"

moto: 
    marca: { type: varchar(255), required: true } 
    matricula: { type: integer, required: true } 

今私は、この基準を持っている:私は、基準コードを呼び出すと

$c = new Criteria(); 
    $c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')'); 
    $max_matricula = MotoPeer::doSelect($c); 
    var_dump($max_matricula); 
    return $max_matricula; 

それは大丈夫動作しますが、以下これら三つの通知 があったされています。

ライン379 コールに2 では/ opt/LAMPP/htdocsに/ prueba/libに/ モデル/ OM/BaseMotoPeer.php:(!):オフセット未定義

SF 1.4/1.4

お知らせを推進

時間メモリ機能場所1 0.0008 328076

{メイン}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->ディスパッチを()スタック
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->ディスパッチ()
../ sfContext.class.php:フォワード170 4
0.1981 4350256 sfController->()../ sfFrontWebController.class .PHP:48 5
0.2134 4641000 sfFilterChain->)(実行
../sfController.class.php:238 6
0.2138 4641808 sfRenderingFilter->(実行)
../ sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain-> execute()../ sfRenderingFilter.class.php:33 8
0.2143 4642588 sfExecutionFilter->()を実行
../ sfFilterChain.class.php:53 9
0.2144 4643308 sfExecutionFilter-> handleAction()
../ sfExecutionFilter.class.php:42 10 0.2144 4643308 sfExecutionFilter - > ExecuteActionメソッド() ../ sfExecutionFilter.class.php:78 11 0.2144 4643336 sfActions->実行()../sfExecutionFilter.class.php:92 12 0.2147 4644160 motoActions-> executePrueba()
.. /sfActions.class.php:60 13
0.2212 5026172 MotoPeer :: prueba()../actions.class.php:14 14 0.2254 528559 2 BaseMotoPeer ::のdoSelect()
../MotoPeer.php:26 15 0.2493 5756176 BaseMotoPeer :: populateObjects( )../BaseMotoPeer.php:241 16
0.2493 5756568 BaseMotoPeer :: getPrimaryKeyHashFromRow( )../BaseMotoPeer.php:400

(! )注意:オフセット不定:1 は/ opt/LAMPP/htdocsに/ prueba/libに/ モデル/ OM/BaseMoto.phpでライン184コール スタック

時間メモリー機能場所1 0に。0008 328076

{メイン}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->ディスパッチ()
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->ディスパッチ( )
../ sfContext.class.php:170 4
0.1981 4350256 sfController->フォワード()../ sfFrontWebController.class.php:48 5
0.2134 4641000 sfFilterChain->実行()
.. /sfController.class.php:238 6
0.2138 464 1808 sfRenderingFilter->()を実行
../ sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain->()../ sfRenderingFilter.class.php実行:33 8
0.2143 4642588 sfExecutionFilter->が実行()
../ sfFilterChain.class.php:53 9
0.2144 4643308 sfExecutionFilter-> handleAction()
../ sfExecutionFilter.class.php:42 10 0.2144 4643308 sfExecutionFilter-> ExecuteActionメソッド() ../sfExecutionFilter.class.php:78 11 0.2144 4643336 sfActions-> execute()../sfExecutionFilter.class.php:92 12 0.2147 4644160 motoActions-> executePrueba()
../sfActions.class.php:60 13
0.2212 5026172 MotoPeer :: prueba()../actions.class.php:14 14 0.2254 5285592 BaseMotoPeer ::のdoSelect ()
../MotoPeer.php:26 15 0.2493 5756176 BaseMotoPeer :: populateObjects( )../BaseMotoPeer.php:241 16
0.2578 5953424 BaseMoto->水和物()../BaseMotoPeer.php:408

(! )注意:オフセット不定:2 は/ opt/LAMPP/htdocsに/ prueba/libに/ モデル/ OM/BaseMoto.phpでライン185コール スタック上

時間メモリー機能場所1 0.0008 328076

{メイン}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->ディスパッチ()
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->ディスパッチ()
../ sfContextの.class.php:170 4
0.1981 4350256 fController->フォワード()../ sfFrontWebController.class.php:48 5
0.2134 4641000 sfFilterChain->)(実行
../sfController.class.php:238 6
0.2138 4641808 sfRenderingFilter->実行( )
../ sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain->実行()../ sfRenderingFilter.class.php:33 8
0.2143 4642588 sfExecutionFilter->実行()
../sfFilterChain.class.php:53 9
0.2144 4643308 sfExecutionFilter-> handleAction()
../sfExecutionFilter.class.php:42 10 0.2144 4643308 sfExecutionFilter-> executeAction() ../ sfExecutionFilter.class.php:78 11 0.2144 4643336 sfActions->実行()../sfExecutionFilter.class.php:92 12 0.2147 4644160 motoActions-> executePrueba()
../sfActions.class.php:60 13
0.2212 5026172 MotoPeer :: prueba()../actions.class.php:14 14 0.2254 5285592 BaseMotoPeer ::のdoSelect()
../MotoPeer.php:26 15 0.2493 5756176 BaseMotoPeer :: populateObjects( )../BaseMotoPeer.php:241 16
0.2578 5953424 BaseMoto->水和物()

を../BaseMotoPeer.php:

EDIT:最初の通知は、モデルのフィールドの前に "id:〜"と書いていないので表示されます。ここでは、第二と第三の通知の原因となる行を行く:

/** 
    * Hydrates (populates) the object variables with values from the database resultset. 
    * 
    * An offset (0-based "start column") is specified so that objects can be hydrated 
    * with a subset of the columns in the resultset rows. This is needed, for example, 
    * for results of JOIN queries where the resultset row includes columns from two or 
    * more tables. 
    * 
    * @param  array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) 
    * @param  int $startcol 0-based offset column which indicates which restultset column to start with. 
    * @param  boolean $rehydrate Whether this object is being re-hydrated from the database. 
    * @return  int next starting column 
    * @throws  PropelException - Any caught Exception will be rewrapped as a PropelException. 
    */ 
    public function hydrate($row, $startcol = 0, $rehydrate = false) 
    { 
     try { 

var_dump($row); 

    $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; 
    $this->marca = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;//184 
    $this->matricula = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;//185 

私が考える第2、第3の通知があるため、私はちょうど1列(maatricula)を取得していた基準に示されたされています。しかし、それをどうやって行うのですか?

ハビエル

+0

通知に記載されている行を投稿すると、... – greg0ire

+0

こんにちは、ありがとう、私はより多くの情報を掲載しました。 – ziiweb

答えて

1

あなたが「AddSelectColumn」メソッドを使用する場合:

$c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')'); 

を、あなたは、オブジェクトを水和することはできません - あなたはすべての列を選択されていません。

MotoPeer::doSelect($c); 

が代わりにこれを行う:したがって呼び出すことはありません

$c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')'); 
$stmt = MotoPeer::doSelectStmt($c); 
$max_matricula = $stmt->fetchColumn(0); 

ここでは、SQL文を実行し、変数$ max_matriculaに興味を持っている単一の値を取得します。

関連する問題