대부분의 사람들은 특정 테이블 클래스를 작성하지 않지만 CLI 툴을 통해 자동 생성 된 Doctrine_Record 클래스를 사용합니다. 즉, 귀하의 경우 만약 당신이 항상 ID의 DESC 모든 결과를 주문하고 10 모든 쿼리를 제한하는 것을 발견하면
, 당신은
//instantiate your record class
$model = new TableName();
$model->getTable() //returns an instance of Doctrine_Table for current Doctrine_Record
->createQuery() //returns a Doctrine_Query instance with the current table loaded
->orderBy("id DESC")
->limit(10)
->execute();
과 같은 작업을 수행 할 수 있습니다, 당신은 또한 교리에 후크를 추가 할 수 있습니다 좋아요 기록 수업
class TableName extends Base_TableName //most Doctrine Records extend a base record with config info
{
//this hook will order all by id and limit all queries to 10
public function preDqlSelect(Doctrine_Event $event)
{
$event->getQuery()
->addOrderBy("id DESC")
->limit(10);
}
}