/** * Log method, must be in all classes for Logger class functionality. * * @param string $type Log message type from Logger class. * @param string $message Message text. * @param int $time Timestamp. * * @return int Number of affected rows. * @throws \Asymptix\db\DBCoreException If some database error occurred. */ public static function log($type, $message, $time = null) { if (is_null($time)) { $time = time(); } $query = "INSERT INTO " . self::TABLE_NAME . " (type, message, count, last_seen) VALUES (?, ?, 1, ?)\n ON DUPLICATE KEY UPDATE count = count + 1, last_seen = ?"; try { return DBCore::doUpdateQuery($query, "ssss", [$type, $message, date("Y-m-d H:i:s", $time), date("Y-m-d H:i:s", $time)]); } catch (\Asymptix\db\DBCoreException $e) { print $e->getMessage(); } }
public static function log($type, $called, $script, $line, $message) { if (is_null($called)) { $called = $_SERVER['SCRIPT_NAME']; } $errorTypes = array(); if ($type === 0) { $errorTypes[] = "E_LOG_INFO"; } else { for ($i = 0; $i < 15; $i++) { $errorType = self::friendlyErrorType($type & pow(2, $i)); if (!empty($errorType)) { $errorTypes[] = $errorType; } } } $query = "INSERT INTO " . self::TABLE_NAME . " (type, error_type, called, script, line, message, count) VALUES (?, ?, ?, ?, ?, ?, 1)\n ON DUPLICATE KEY UPDATE count = count + 1, last_seen = ?"; return DBCore::doUpdateQuery($query, "isssiss", array($type, implode(", ", $errorTypes), $called, $script, $line, $message, date("Y-m-d H:i:s"))); }
/** * Saves removement flag to the database. * * @return integer Returns the number of affected rows on success, and -1 if * the last query failed. */ public function saveRemovementFlag() { return DBCore::doUpdateQuery("UPDATE " . static::TABLE_NAME . "\n SET removed = ?\n WHERE " . static::ID_FIELD_NAME . " = ?\n LIMIT 1", "ii", array($this->removed, $this->id)); }
/** * Executes SQL query. * * @param boolean $debug Debug mode flag. * * @return mixed Statement object or FALSE if an error occurred if SELECT * query executed or number of affected rows on success if other * type of query executed. */ public function go($debug = false) { if ($debug) { DBQuery::showQueryDebugInfo($this->query, $this->types, $this->params); } else { if ($this->isSelect()) { return DBCore::doSelectQuery($this); } else { return DBCore::doUpdateQuery($this); } } }
/** * Executes SQL query. * * @param bool $debug Debug mode flag. * * @return mixed Statement object or FALSE if an error occurred if SELECT * query executed or number of affected rows on success if other * type of query executed. */ public function go($debug = false) { if ($debug) { $this->debug(); } else { if ($this->isSelector()) { return DBCore::doSelectQuery($this); } return DBCore::doUpdateQuery($this); } }