Login +

Documentation

SLS_FrontModel::searchModels

Since SillySmart 1.0

Description

Search of n objects of models
public array searchModels ( [ string $table ] , [ array $joins ] , [ array $clause ] , [ array $group ] , [ mixed $order ] , [ array $limit ] );

Parameters

  • string $table
    the current table to list (default: empty => current model)
  • array $joins
    the table(s) to join with current table (default: empty => no join) If you want to natural join:
    array("table_2","table_3","...","table_n")
    will give 'SELECT * FROM table_1 NATURAL JOIN table_2 NATURAL JOIN table_3 ... NATURAL JOIN table_n' If you want to join with a specific column:
    array(0=>array("table"=>"table_2","column"=>"column_2"),1=>array("table"=>"table_3","column"=>"column_3"))
  • array $clause
    the clause wanted (default: empty => no clause)
     array
     (
    ||t||||t||[0] => array
    ||t||||t||||t||||t||(
    ||t||||t||||t||||t||||t||["column"] = "column_1",
    ||t||||t||||t||||t||||t||["value"] = "value_1", // or array('value1','value2','...','valueN') if "in" mode
    ||t||||t||||t||||t||||t||["mode"] = "like" or "notlike" or "beginwith" or "endwith" or "equal" or "notequal" or "lt" or "le" or "ge" or "gt" or "null" or "notnull" or "in"
    ||t||||t||||t||||t||)
    ||t||||t||[1] => array
    ||t||||t||||t||||t||(
    ||t||||t||||t||||t||||t||["column"] = "user_department",
    ||t||||t||||t||||t||||t||["value"] = "75", // or array('value1','value2','...','valueN') if "in" mode
    ||t||||t||||t||||t||||t||["mode"] = "like" or "notlike" or "beginwith" or "endwith" or "equal" or "notequal" or "lt" or "le" or "ge" or "gt" or "null" or "notnull" or "in"
    ||t||||t||||t||||t||)
     )
     
  • array $group
    a group by (default: empty => no group by)
    array("column_1","column_2","...","column_n")
  • mixed $order
    the order you want (default: empty => ORDER BY primary key ASC)
     array
     (
     ||t||||t||[0] => array
     ||t||||t||||t||||t||(
     ||t||||t||||t||||t||||t||["column"] = "column_1",
     ||t||||t||||t||||t||||t||["order"] = "asc"
     ||t||||t||||t||||t||)
     ||t||||t||[1] => array
     ||t||||t||||t||||t||(
     ||t||||t||||t||||t||||t||["column"] = "column_2",
     ||t||||t||||t||||t||||t||["order"] = "desc"
     ||t||||t||||t||||t||)
     )
     
    or string "rand()"
  • array $limit
    the limit you want (default: empty for all recordsets)
    array("start" => "10", "length" => "30")

Return

array $objects
array of PDO objects

Exemples

  •  // Find all recordsets
     $object->searchModels();
  •  // Find all recordsets where column_name like 'is'
     $object->searchModels("table_name",array(),array(0=>array("column" => "colu_name", "value" => "is", "mode" => "like")));

Comments

No comment on this function, be the first !

Add your comment

You must login/register to post a reply.