public function collect() { $conn =& FCore::GetDefaultConnection(); $this->rank = $conn->quick_query( "SELECT max(".USERMANUAL_RANK.") FROM ".USERMANUAL, true); if (!$this->rank) { $this->rank = 1; } else { $this->rank = $this->rank[0]["max(".USERMANUAL_RANK.")"]; $this->rank++; } }
public static function SetCount($key, $count) { try { $db =& FCore::GetDefaultConnection(); $db->quick_query( "INSERT INTO ".self::FCORE_COUNTER." SET ".self::NAME."='$key', ".self::COUNT."=$count ON DUPLICATE KEY UPDATE ".self::COUNT."=$count"); $db->commit(); return $count; } catch(Exception $e) { $db->rollback(); throw new DBCounterException($e->getMessage()); } }
private function __construct($forum_data) { $this->forum_id = $forum_data[self::FORUM_ID]; $this->post_datatype = $forum_data[self::POSTDATATYPE]; $this->time_made = $forum_data[self::TIMEMADE]; $this->last_used = $forum_data[self::LASTUSED]; $this->origin_type = $forum_data[self::ORIGIN_TYPE]; $this->origin_id = $forum_data[self::ORIGIN_ID]; $this->metadata = $forum_data[self::METADATA]; $this->db =& FCore::GetDefaultConnection(); }
public static function DeleteAllFromOriginType($origin_type) { if ($origin_type == null || $origin_type == "") { throw new DBDataTypeException('$origin_type cannot be null or empty'); } $db = null; try { $db =& FCore::GetDefaultConnection(); $datatype_ids = $db->quick_query( "SELECT ".self::DATATYPE_ID.", ".self::DATATYPE." FROM ".self::TABLE_BASE." WHERE ".self::ORIGIN_TYPE."='$origin_type'", true); if ($datatype_ids == null) { return null; } foreach($datatype_ids as $data_set) { $db->quick_query( "DELETE FROM ".self::TABLE_BASE." WHERE ".self::DATATYPE_ID."=".$data_set[self::DATATYPE_ID]); $db->quick_query( "DELETE FROM ".$data_set[self::DATATYPE]." WHERE ".self::DATATYPE_ID."=".$data_set[self::DATATYPE_ID]); } $db->commit(); return $datatype_ids; } catch(Exception $e) { if ($db != null) { $db->rollback(); } throw new DBDataTypeException($e->getMessage()); } }
/** * * @param <type> $logIDs */ public static function delete($logIDs) { try { $deletes = ""; if (is_array($logIDs)) { foreach($logIDs as $id) { if ($deletes != "") { $deletes .= " || "; } $deletes .= self::LOGID."=$id"; } } else if (is_numeric($logIDs)) { $deletes = self::LOGID."=$logIDs"; } else { throw new InvalidArgumentException('$logIDs'); } $db =& FCore::GetDefaultConnection(); $db->quick_query("DELETE FROM ".self::FCORE_LOG." WHERE $deletes"); $db->commit(); } catch(Exception $e) { $db->rollback(); throw new DBLoggerException($e->getMessage()); } }
/** * */ public function pushToDatabase($level, $column, $table){ $conn = FCore::GetDefaultConnection(); $count = 1; foreach($this->logs as $log){ if ($level > $log[self::LEVEL]){ continue; } try { $insert = $conn->escape_string( "$count [".$this->levelToTagString($log[self::LEVEL])."]". " FILE: ".$log[self::FILE]. " LINE: ".$log[self::LINE]. " MSG: ".$log[self::MSG]); $conn->quick_query("INSERT INTO $table SET $column='$insert'"); $count++; } catch(Exception $e){} } $conn->commit(); }
/** * * @param <type> $message_id * @param <type> $origin_type * @param <type> $origin_id * @param <type> $value */ public static function SetSeen($message_id, $origin_type, $origin_id, $value) { if (!is_numeric($message_id)) { throw new DBMessageException('$message_id must be numeric'); } if (!is_string($origin_type)) { throw new DBMessageException('$origin_type must be a string'); } if (!is_numeric($origin_id)) { throw new DBMessageException('$origin_to_id must be numeric'); } if (!is_numeric($value)) { throw new DBMessageException('$value must be numeric'); } $db = false; try { $db =& FCore::GetDefaultConnection(); $db->quick_query( "UPDATE FROM ".self::FCORE_MESSAGE_TOS." SET ".self::SEEN."=$value WHERE ".self::MESSAGE_ID."=$message_id AND ".self::ORIGIN_TYPE."='$origin_type' AND ".self::ORIGIN_ID."=$origin_id"); $db->commit(); } catch(Exception $e) { if ($db) { $db->rollback(); } throw new DBMessageException($e->getMessage()); } }
/** * * @param <type> $table_name * @param <type> $pri_key_name * @param <type> $conn * @param <type> $data_rules */ public function __construct($table_name, $pri_key_name, $conn = null, $data_rules = null) { $this->config_map = array(); $this->config_map[self::DB_PRI_KEY_NAME] = $pri_key_name; $this->config_map[self::DB_TABLE_NAME] = $table_name; $this->config_map[self::DB_DATA_RULES] = $data_rules; if ($conn == null) { $this->conn =& FCore::GetDefaultConnection(); } else { $this->conn =& $conn; } }