2011-01-09 8 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 에서/옵션/lampp를/htdocs에/prueba/lib 디렉토리/ 모델/OM/BaseMotoPeer.php : (!) : 오프셋 정의되지 않은

김포 1.4/1.4

공지 사항을 추진

시간 메모리 기능 위치 1 0.0008 328076

{주}() ../frontend_dev.php:0 2 0.1974 4,333,236 sfContext-> 파견() 스택
백45경1천5백15조5백36억9천1백36만3천2백10 ../frontend_dev.php:13 3 0.1974 4,333,264 sfFrontWebController-> 디스패치()
../ sfContext.class.php : 기대 170 4
0.1981 4,350,256 sfController->() ../ sfFrontWebController.class .PHP 48 5
0.2134 4,641,000 sfFilterChain->()
../sfController.class.php을 실행 sfRenderingFilter- 238 6
0.2138 4,641,808을>) (실행
../ sfFilterChain.class.php 53 7
0.2138 4641808 sfFilterChain-> execute() ../ sfRenderingFilter.class.php : 33 8
0.2144 4,643,308 sfExecutionFilter-> handleAction()
../ sfExecutionFilter.class.php : 42 10 0.2144 4,643,308 sfExecutionFilter 1백62경7천5백52조3천1백49억6천45만3천2백10 0.2143 4,642,588 sfExecutionFilter->()
../ sfFilterChain.class.php 실행할 -> executeAction() ../ sfExecutionFilter.class.php 78 11 0.2144 4,643,336 sfActions-> 실행() ../sfExecutionFilter.class.php 92 12 0.2147 4,644,160 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 5,756,176 BaseMotoPeer :: populateObjects ( ) ../BaseMotoPeer.php 241 16
0.2493 5,756,568 BaseMotoPeer :: getPrimaryKeyHashFromRow ( ) ../BaseMotoPeer.php : 400

(!) 공지 사항은 : 오프셋 정의되지 않은 : 1 /옵션/lampp를/htdocs에/prueba/lib 디렉토리/ 모델/OM/BaseMoto.php 라인 (184) 전화 스택

시간 메모리 기능 위치 1 0.0,008 328,076

메인 {}() ../frontend_dev.php:0 2 0.1974 4,333,236 sfContext-> 디스패치()
../frontend_dev.php:13 3 0.1974 4,333,264 sfFrontWebController-> 디스패치 ()
../ sfContext.class.php 170 4
0.1981 4,350,256 sfController-> 전달() ../ sfFrontWebController.class.php 48 5
0.2134 4,641,000 sfFilterChain-가> 실행()
.. /sfController.class.php : 238 6
0.2138 464 1,808 sfRenderingFilter->()
../ sfFilterChain.class.php 실행 53 7
0.2138 4,641,808 sfFilterChain->을 실행() ../ sfRenderingFilter.class.php 33 8
0.2143 4,642,588 sfExecutionFilter->를 수행()
../ sfFilterChain.class.php 53 9
0.2144 4,643,308 sfExecutionFilter-> handleAction()
../ sfExecutionFilter.class.php 42 10 0.2144 4,643,308 sfExecutionFilter-> executeAction() ../sfExecutionFilter.class.php : 78 11 0.2144 4643336 sfActions-> execute() ../sfExecutionFilter.class.php : 92 12 0.2147 4,644,160 motoActions-> executePrueba()
../sfActions.class.php 60 13
0.2212 5,026,172 MotoPeer :: prueba() ../actions.class.php:14 14 0.2254 5,285,592 BaseMotoPeer :: doSelect()
../MotoPeer.php:26 15 0.2493 5,756,176 BaseMotoPeer :: populateObjects ( ) ../BaseMotoPeer.php 241 16
0.2578 5,953,424 BaseMoto-> 수화물() ../BaseMotoPeer.php:408

(!) 공지 사항은 : 오프셋 정의되지 않은 : 2 /옵션/lampp를/htdocs에/prueba/lib 디렉토리/ 모델/OM/BaseMoto.php에 라인 185 전화 스택에

시간 메모리 기능 위치 1 0.0008 328076

{()} 메인 ../frontend_dev.php:0 2 0.1974 4,333,236 sfContext-> 디스패치()
../frontend_dev.php:13 3 0.1974 4,333,264 sfFrontWebController-> 디스패치()
../ sfContext .class.php : 170 4
0.1981 4350256 s fController-> 전달() ../ sfFrontWebController.class.php 48 5
0.2134 4,641,000 sfFilterChain-을> (실행)
../sfController.class.php : 238 6
0.2138 4,641,808은 sfRenderingFilter-> 실행 ()
../ sfFilterChain.class.php 53 7
0.2138 4,641,808 sfFilterChain->() ../ sfRenderingFilter.class.php 실행 : 33 8
0.2143 4,642,588 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 4,643,336 sfActions-을> (실행) ../sfExecutionFilter.class.php 92 12 0.2147 4,644,160 motoActions-> executePrueba()
../sfActions.class.php 60 13
0.2212 5,026,172 MotoPeer :: prueba() ../actions.class.php:14 14 0.2254 5,285,592 BaseMotoPeer :: doSelect()
../MotoPeer.php:26 15 0.2493 5,756,176 BaseMotoPeer :: populateObjects ( ) ../BaseMotoPeer.php 241 16
0.2578 5,953,424 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 

내가 생각하기에, 두 번째와 세 번째 사항 때문에 난 그냥 하나의 열 (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에 관심있는 단일 값을 가져옵니다.