public static function filter_month(\System\Database\Query $query, $val) { $date = new \DateTime($val); $date->modify('midnight'); $start = clone $date; $end = clone $date; $start->modify('first day of this month'); $end->modify('last day of this month')->modify('tomorrow'); $conds = array("start >= '" . $start->format('Y-m-d H:i:s') . "'", "start < '" . $end->format('Y-m-d H:i:s') . "'"); return $query->where($conds); }
public function write($id, $cargo) { extract($this->config); // if the session is set to never expire // we will set it to 1 year if ($lifetime == 0) { $lifetime = 3600 * 24 * 365; } $expire = time() + $lifetime; $data = serialize($cargo); if ($this->exists) { Query::table($table)->where('id', '=', $id)->update(array('expire' => $expire, 'data' => $data)); } else { Query::table($table)->insert(array('id' => $id, 'expire' => $expire, 'data' => $data)); } }
public function count($sql) { $result = $this->query($sql); return \System\Database\Query::first_val($result->fetch()); }
/** * Magic method for calling other Query methods * * @param string * @param array * @return mixed */ public static function __callStatic($method, $arguments) { $obj = Query::table(static::$prefix . static::$table)->apply(get_called_class()); if (method_exists($obj, $method)) { return call_user_func_array(array($obj, $method), $arguments); } }
/** * Delete object from database * * @return bool */ public function drop() { return \System\Database\Query::simple_delete($this::get_table(), array($this::get_id_col() => $this->id)); }