Complex ORM in DooPHP

396 Views Asked by At

I have use DooPhp for a small project. But i have problem with ORM query style.

select * from table_name where table ='aaa' order by table_name_id desc To ORM style:

$vararray = Doo::db()->find('table_name', array(
                                    'where'=>'table=?','param' => array($this->params['table_name_id']),array('desc' => 'id'));

But more complex query like:

select * from table_name where table ='aaa' and table1 like '%value%' order by table_name_id desc

I can not finish it use ORM style.

1

There are 1 best solutions below

1
On

In a model extending DooSmartModel you can create a function like this:

   /** @params array of values **/ public functiong getTables($params){
return Doo::db->find(array(
"where" => "table = '$params[0]' and table1 like'%$param[1]'",
"desc" => "table_name_id"
)
)
}

after add a __construct function ( obviously )

  function __construct(){

    parent::$className = __CLASS__;   

}