function __construct() { $IP = Session::IP(); \Radical\DB::Q('INSERT INTO session (session_ip,session_time) VALUES(' . \Radical\DB::E($IP) . ',' . time() . ') ON DUPLICATE KEY UPDATE session_time=' . time()); $this->id = \Radical\DB::insertId(); parent::__construct(); }
function toSQL() { $a = $this->a; if (is_string($a) && strpos($a, '(') === false && strpos($a, '`') === false) { $at = ''; foreach (explode('.', $a) as $v) { if ($at) { $at .= '.'; } $at .= '`' . $v . '`'; } $a = $at; } if ($this->b instanceof IComparison && count($this->b)) { return $a . ' ' . (string) $this->b; } $op = $this->operation; $b = $this->b; if ($this->autoNull && $b === null) { if ($op == '=') { $op = 'IS'; } else { if ($op == '!=' || $op == '<>') { $op = 'IS NOT'; } else { $op = trim(strtoupper($op)); if ($op != 'IS' && $op != 'IS NOT') { throw new \Exception("Invalid operation with NULL"); } } } $this->escaped = true; $b = 'NULL'; } return $a . ' ' . $op . ' ' . ($this->escaped ? $b : \Radical\DB::E($b)); }
function toSQL() { return DB::E((string) $this); }
function toEscaped() { return \Radical\DB::E($this->ip); }
function toSQL() { return DB::E($this->toSQLFormat()); }
function exists() { $sql = 'show tables like ' . \Radical\DB::E($this->getTable()); $res = \Radical\DB::Q($sql); if ($res->Fetch()) { return true; } return false; }