열 ID에서 모두 선택하도록 Zend DB 쿼리를 작성하려면 어떻게해야합니까?모든 ID를 선택하는 Zend Db 쿼리
은 지금까지 나는 시도했다 :
public function getLatestUserID()
{
$ids = $this->select()
->where('id = ?');
return $ids;
}
하지만 아무 소용.
열 ID에서 모두 선택하도록 Zend DB 쿼리를 작성하려면 어떻게해야합니까?모든 ID를 선택하는 Zend Db 쿼리
은 지금까지 나는 시도했다 :
public function getLatestUserID()
{
$ids = $this->select()
->where('id = ?');
return $ids;
}
하지만 아무 소용.
너는 실행 명령을 호출하지 못했습니다.
시도 :
//assuming you are using a DbTable model
public function getLatestUserID()
{
$ids = $this->fetchAll('id');
return $ids;
}
내가, 이런 식으로 할 것 내가 모든 것을 선택() 객체를 사용하기 때문에 :
public function getLatestUserID()
{
$select = $this->select();
//I'm not sure if $this will work in this contex but you can out the table name
$select->from(array($this), array('id'));
$ids = $this->fetchAll($select);
return $ids;
}
처음 두 예는 단지 id
열을 반환해야합니다 이제 실제로 구체적인 검색어를 찾으려는 경우 id
:
public function getLatestUserID($id)
{
$select = $this->select();
$select->where('id = ?', $id);
//fetchAll() would still work here if we wanted multiple rows returned
//but fetchRow() for one row and fetchRowset() for multiple rows are probably
//more specific for this purpose.
$ids = $this->fetchRow($select);
return $ids;
}
getLatestUserID가 포함 된 클래스가 Zend_Db_Table_Abstract를 확장하는지 확인하십시오.
$ids = $this->select()->where('id = ?');
('id =?'); 무엇을 기대하고 당신이 원하는 것은 최신 삽입 된 행의 ID를 사용하는 경우 where('id = ?', $id);
같은 id 값 :
(이 작동하지 않습니다 당신이$lastInsertId = $this->getAdapter()->lastSequenceId('USER_TABLE_SEQUENCE');
를 사용해야 오라클 데이터베이스를 사용하지만 경우)
$lastInsertId = $this->getAdapter()->lastInsertId();
똑똑하고 완벽하게 작동했기 때문에 $ this를 테이블 이름으로 바꿔야했지만 완벽하고 정확하게 필요한 부분이 있습니다. 고맙습니다. – RSM
@ RyanMurphy 예, 테이블 이름에'$ this -> _ name'이 있어야한다는 오류가있었습니다. – RockyFord