Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony1 标准:“;“未定义的偏移量”;_Symfony1_Criteria_Propel_Offset - Fatal编程技术网

Symfony1 标准:“;“未定义的偏移量”;

Symfony1 标准:“;“未定义的偏移量”;,symfony1,criteria,propel,offset,Symfony1,Criteria,Propel,Offset,下面是这个模式,我使用symfony生成了类 并使用生成的form类创建了一对对象 moto: marca: { type: varchar(255), required: true } matricula: { type: integer, required: true } 现在我有了这个标准: $c = new Criteria(); $c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')'); $max_matricu

下面是这个模式,我使用symfony生成了类 并使用生成的form类创建了一对对象

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;
当我调用标准代码时,它工作正常,但这三个注意事项 下面是一些例子

有什么想法吗

sf 1.4/1.4

(!)注意:未定义的偏移量:2英寸 /opt/lampp/htdocs/prueba/lib/ 第379行的model/om/BaseMotoPeer.php 调用堆栈

时间记忆功能位置1 0.0008 328076 {main}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->dispatch()
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->dispatch()
../sfContext.class.php:1704
0.1981 4350256 sfController->forward()/ sfFrontWebController.class.php:48 5
0.2134 4641000 sfFilterChain->执行()
../sfController.class.php:238 6
0.2138 4641808 sfRenderingFilter->execute()
../sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain->执行()/ sfRenderingFilter.class.php:338
0.2143 4642588 sfExecutionFilter->execute()
../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.21474644160 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.2493 5756568 BaseMotoPeer::getPrimaryKeyHashFromRow( )../BaseMotoPeer.php:400

(!)注意:未定义的偏移量:1英寸 /opt/lampp/htdocs/prueba/lib/ model/om/BaseMoto.php在线184调用 堆叠

时间记忆功能位置1 0.0008 328076 {main}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->dispatch()
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->dispatch()
../sfContext.class.php:1704
0.1981 4350256 sfController->forward()/ sfFrontWebController.class.php:48 5
0.2134 4641000 sfFilterChain->执行()
../sfController.class.php:238 6
0.2138 4641808 sfRenderingFilter->execute()
../sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain->执行()/ sfRenderingFilter.class.php:338
0.2143 4642588 sfExecutionFilter->execute()
../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.21474644160 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->hydrate()../BaseMotoPeer.php:408

(!)注意:未定义的偏移量:2英寸 /opt/lampp/htdocs/prueba/lib/ model/om/BaseMoto.php在线调用 堆叠

时间记忆功能位置1 0.0008 328076 {main}()../frontend_dev.php:0 2 0.1974 4333236 sfContext->dispatch()
../frontend_dev.php:13 3 0.1974 4333264 sfFrontWebController->dispatch()
../sfContext.class.php:1704
0.1981 4350256 sfController->forward()/ sfFrontWebController.class.php:48 5
0.2134 4641000 sfFilterChain->执行()
../sfController.class.php:238 6
0.2138 4641808 sfRenderingFilter->execute()
../sfFilterChain.class.php:53 7
0.2138 4641808 sfFilterChain->执行()/ sfRenderingFilter.class.php:338
0.2143 4642588 sfExecutionFilter->execute()
../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.21474644160 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->hydrate()../BaseMotoPeer.php:408

编辑:出现第一个通知,因为我没有在模型的字段前写上“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
我认为,第二个和第三个通知是显示的,因为在标准中,我只得到一列(maatricula)。但如何做到这一点呢

Javier

如果使用“AddSelectColumn”方法:

您不能为对象添加水合物-您没有选择所有列。因此,不要呼吁:

MotoPeer::doSelect($c);
而是这样做:

$c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')');
$stmt = MotoPeer::doSelectStmt($c);
$max_matricula = $stmt->fetchColumn(0);
这里执行SQL语句,并将感兴趣的单个值提取到变量$max\u matricula中。

如果使用“AddSelectColumn”方法:

您不能为对象添加水合物-您没有选择所有列。因此,不要呼吁:

MotoPeer::doSelect($c);
而是这样做:

$c->addSelectColumn('MAX('.MotoPeer::MATRICULA.')');
$stmt = MotoPeer::doSelectStmt($c);
$max_matricula = $stmt->fetchColumn(0);
这里执行SQL语句并将感兴趣的单个值提取到变量$max\u matricula中。