Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
 public function count($sql)
 {
     $result = $this->query($sql);
     return \System\Database\Query::first_val($result->fetch());
 }
Esempio n. 4
0
 /**
  * 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);
     }
 }
Esempio n. 5
0
 /**
  * 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));
 }