converting simple query to cake query?

前端 未结 3 1286
悲&欢浪女
悲&欢浪女 2021-01-28 20:05

Actually I have 1 query but I am unable to convert it into CakePHP query format.

$result = \"select 
             * from esl_userresults
           where 
               


        
3条回答
  •  悲&欢浪女
    2021-01-28 20:47

    You can easily run direct sql queries on cake using e.g.: $this->Picture->query("SELECT * FROM pictures LIMIT 2;"); (cake manual)

    Or try something simillar to this:

        $result = Esl_Userresults->find('all' , array('conditions' => array(
                 "Esl_Userresults.esl_songID" => "Esl_Lyrics.id",
                 "Esl_Lyrics.song_name LIKE" => '%'.$esl_keyword.'%'),
                  'recursive' => 1)
                  );
    

    ..given that you have properly linked Esl_Userresults and Esl_Lyrics models.

提交回复
热议问题