The standard way to make a query against a database table is to create a model and create a function within it , for example :
<pre> <code> <?php
use Phalcon\Mvc\Model; use Phalcon\Mvc\Model\Query;
class Client extends Model {
function lireParCritere($critere) {
$sSQL = "
SELECT c.clt_id as clt_id,c.clt_cin_pass,c.clt_nom,c.clt_prenom,c.clt_tel,
c.clt_adresse,c.clt_comment,CONCAT_WS(
' ',
c.clt_nom,
c.clt_prenom
) AS noms
FROM client as c WHERE 1 = 1 ";
if(isset($critere["clt_id"]) && $critere["clt_id"] != "") {
$sSQL .= "AND c.clt_id = '" . $critere["clt_id"] . "' ";
}
$sSQL .= " ORDER BY noms";
$query = new Query($sSQL,$this->getDI());
$ret = $query->execute();
return $ret;
}
} </code> </pre>
What is the way to make a query against a database view ?