Mah, una cosa tipo:
Codice PHP:
class UserRecord{
const FIND_ALL_QUERY = "SELECT * FROM utenti LEFT JOIN tecnici ON tec_idtecnico = idutente";
....
public function getUtenti(Array $criteria = array() ,Array $value = array()){
$sql = self::FIND_ALL_QUERY;
foreach($criteria as $i => $c)
{
if($i == 0)
$sql .= " WHERE ";
if($i > 0)
$sql .= " AND ";
$sql .= "(".$c.")";
}
return $this->fetchAll($sql,$value);
}
public function getUtentiBy(Array $mapFieldsValue = array())
{
//considerando una mappa del tipo nomeField => valore
$fields = array_map(
function($item)
{
return $item." = :".$item;
},
array_keys($mapFieldsValue));
$values = array_values($mapFieldsValue);
return $this->getUtenti($fields, $values);
}
public function fetchAll($sql, array $params = array()){
return $this->executeQuery($sql, $params)->fetchAll(PDO::FETCH_ASSOC);
}
}
? non provata/testata/nulla, giusto buttata lì ... io e l'active record non andiamo molto d'accordo cmq