Remove Zend_Db

This commit is contained in:
Michael RICOIS 2017-02-06 15:47:13 +01:00
parent 264fb038ec
commit a468c819db

View File

@ -5,10 +5,23 @@ class Scores_Ws_Trigger
protected $event;
protected $events = null;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
public function __construct($event, $userInfos)
{
$this->event = $event;
$this->userInfos = $userInfos;
$this->conn = Zend_Registry::get('doctrine');
}
/**
@ -21,21 +34,27 @@ class Scores_Ws_Trigger
$service = 'default';
}
$model = new Application_Model_Sdv1ClientsServicesTrigger();
$sql = $model->select()
->where('event=?', $this->event)
->where('idClient=?', $this->userInfos['idClient'])
->where('service=?', $service)
->where('login=? OR login=""', $login);
$result = $model->fetchAll($sql);
if (count($result)>0) {
foreach ($result as $item) {
$sql = "SELECT * FROM sdv1.clients_services_trigger
WHERE idClient=:client AND service=:service AND (login=:login OR login='')";
$stmtNb = 0;
try {
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$stmtNb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($stmtNb > 0) {
while ($item = $stmt->fetch(PDO::FETCH_OBJ)) {
$tmp->action = $item->action;
$tmp->params = json_decode($item->actionParams, true);
$this->events[] = $tmp;
}
}
return count($result);
return $stmtNb;
}
/**
@ -86,24 +105,25 @@ class Scores_Ws_Trigger
}
try {
$model = new Application_Model_JoSurveillancesSite();
$data = array(
'source' => $args['source'],
'login' => $this->userInfos['login'],
'email' => $this->userInfos['email'],
'siren' => $args['siren'],
'nic' => $args['nic'],
'ref' => $ref,
$this->conn->insert('jo.surveillances_site', array(
'source' => $args['source'],
'login' => $this->userInfos['login'],
'email' => $this->userInfos['email'],
'siren' => $args['siren'],
'nic' => $args['nic'],
'ref' => $ref,
'encoursClient' => 0,
'rs' => $args['Nom'],
'cp' => $args['CP'],
'ville' => $args['Ville'],
'rs' => $args['Nom'],
'cp' => $args['CP'],
'ville' => $args['Ville'],
'dateAjout' => date('Y-m-d'),
'dateSuppr' => 0,
);
$model->insert($data);
));
return true;
} catch (Zend_Db_Exception $e) {
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
return false;