2 namespace callnotifier;
4 class Logger_CallDb extends Logger_CallBase
7 * Create new detailler object
9 * @param string $dsn PDO connection string, for example
10 * 'mysql:host=dojo;dbname=opengeodb'
11 * @param string $username Database username
12 * @param string $password Database password
14 public function __construct($dsn, $username, $password)
17 $dsn, $username, $password,
19 \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
20 \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC
23 $this->stmt = $this->db->prepare(
24 'INSERT INTO finished ('
30 . ', call_from_location'
33 . ', call_to_location'
41 . ', :call_from_location'
44 . ', :call_to_location'
50 public function log($type, $arData)
52 if ($type != 'finishedCall') {
56 $call = $arData['call'];
57 $this->addUnsetVars($call);
59 $ret = $this->stmt->execute(
61 'call_start' => date('Y-m-d H:i:s', $call->start),
62 'call_end' => date('Y-m-d H:i:s', $call->end),
63 'call_type' => $call->type,
64 'call_from' => $call->from,
65 'call_from_name' => $call->fromName,
66 'call_from_location' => $call->fromLocation,
67 'call_to' => $call->to,
68 'call_to_name' => $call->toName,
69 'call_to_location' => $call->toLocation,
70 'call_length' => $call->end - $call->start
75 'Error logging call to database: '
76 . implode(' / ', $this->stmt->errorInfo())