protected function run_query($sql, array $params = null) { $stmt = false; try { $stmt = $this->db->prepare($sql); } catch (PDOException $e) { log::error('Error preparing query on database: ' . $this->connectDetails['db'] . ' ' . $e->getMessage()); } if (!$stmt) { return false; } if (!call_user_func(array($stmt, 'execute'), $params)) { $this->last_error = $stmt->errorInfo(); log::$errorDetails = $this->last_error(); log::error('Query executiong failed: ' . $this->last_error[2]); } return $stmt; }
public function sp($sql, array &$params, $options = array()) { if (!isset($this->db)) { if (error_reporting() !== 0) { log::error('Error running database query. Database connection not initialized.'); } return false; } if (isset($options) && !is_array($options)) { $options = array(); } $result = sqlsrv_query($this->db, $sql, $params, $options); if ($result === false && error_reporting() !== 0) { log::$errorDetails = $this->last_error(); log::error('Error running query on database: ' . $this->connectDetails['db']); } if ($result !== false) { sqlsrv_next_result($result); } return $result; }