1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
$params = array(
'host' => 'localhost' ,
'username' => 'user' ,
'password' => 'password' ,
'dbname' => 'database'
);
try {
$db = Zend_Db::factory('PDO_MYSQL', $params);
$db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
}
$statement = 'SELECT `campaigns`.*, count(1) AS `calls`
FROM `campaigns`, `companies`, `establishments`
WHERE (
`campaigns`.`active` = ?
AND `establishments`.`company`=`companies`.`id`
AND `establishments`.`callback`<NOW()
AND `campaign`=`campaigns`.`id`
)
GROUP BY `campaigns`.`id`
ORDER BY `campaigns`.`last_update` ASC';
$resultSet = $db->fetchAll($statement,1 ); |
Partager