开发者

get value in action class

how can i get numb开发者_如何学Pythoner ID in action? for example

class jobActions extends sfActions
{
      public function executeIndex(sfWebRequest $request)
      {
        $this->jobeet_jobs = Doctrine::getTable('JobeetJob')
          ->createQuery('a')
          ->where('id = 3')
          ->execute();

        echo $this->jobeet_jobs->getId(); //doesnt work
      }

      public function executeTest(sfWebRequest $request)
      {
         $this->id = $this->jobeet_jobs->getId(); /doesnt work
      }
}


In your executeIndex function you retrieve a Doctrine_Collection (a list). Replace ->execute(); with fetchOne();

Or you use some of the following handy functions:

->find($yourID); // Returns ONE object
->findByColumnnamehere($yourValue); // Returns LIST of objects
->findOneByColumnnamehere($yourValue); // Returns ONE object


As execute returns an array of objects, you either need to iterate through them recieving the ids or you use $this->jobeet_jobs = Doctrine::getTable('JobeetJob') ->createQuery('a') ->where('id = 3') ->fetchOne();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜