/** * getQuery * * @param bool $new * * @return Query */ public static function getQuery($new = false) { if (!static::$query || $new) { static::$query = new Query(); } return static::$query; }
/** * getQuery * * @param bool $new * * @return \JDatabaseQuery */ public static function getQuery($new = false) { if (!static::$query || $new) { static::$query = \JFactory::getDbo()->getQuery(true); } return static::$query; }
public static function getTicketByID($id) { $instance = new static(); $sql = $instance->query("SELECT * FROM " . self::$table . " WHERE id=" . $id); if ($sql->execute()) { //$result_set =$sql->fetch(PDO::FETCH_ASSOC) ; $object_array = array(); while ($row = $sql->fetch(\PDO::FETCH_ASSOC)) { $object_array[] = static::instantiate($row); } return !empty($object_array) ? array_shift($object_array) : false; } }
public static function findByAppId($id) { $instance = new static(); $sql = $instance->query("SELECT * FROM " . static::$table . " where app_id = '" . $id . "'"); if ($sql->execute()) { //$result_set =$sql->fetch(PDO::FETCH_ASSOC) ; $object_array = array(); while ($row = $sql->fetch(\PDO::FETCH_ASSOC)) { $object_array[] = static::instantiate($row); } return !empty($object_array) ? array_shift($object_array) : false; } }
public function __construct() { // Because some hosts are complete // idiotic pieces of shit, let's // strip slashes from input. if (get_magic_quotes_gpc()) { $php_is_the_worst_language_ever_because_of_this = function (&$value) { $value = stripslashes($value); }; array_walk_recursive($_GET, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_POST, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_COOKIE, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_REQUEST, $php_is_the_worst_language_ever_because_of_this); } // Set query string static::$query = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null); // Set request scheme static::$scheme = static::isSecure() ? 'https' : 'http'; // Set host static::$host = strtolower(preg_replace('/:\d+$/', '', trim($_SERVER['SERVER_NAME']))); // Set base url static::$base = static::baseUrl(); // Set the request path static::$request_uri = static::requestPath(); // Set relative uri without query string $uri = explode('?', str_replace(static::$base, '', static::$request_uri)); static::$uri = $uri[0]; // Request segments static::$segments = explode('/', trim(static::$uri, '/')); // Set the request method static::$method = strtolower($_SERVER['REQUEST_METHOD']); // Requested with static::$requested_with = @$_SERVER['HTTP_X_REQUESTED_WITH']; // _REQUEST static::$request = $_REQUEST; // _POST static::$post = $_POST; }
/** * Sets up the request. */ public static function init() { static::$query = new ParameterBag($_GET); static::$post = new ParameterBag($_POST); static::$properties = new ParameterBag(); static::$server = new ParameterBag($_SERVER); static::$headers = static::buildHeaderBag(); static::$method = isset($_POST['_method']) ? $_POST['_method'] : $_SERVER['REQUEST_METHOD']; static::$requestUri = $_SERVER['REQUEST_URI']; static::$scriptName = $_SERVER['SCRIPT_NAME']; static::$basePath = rtrim(str_replace(basename(static::$scriptName), '', static::$scriptName), '/'); static::$pathInfo = str_replace(static::$scriptName, '', static::$requestUri); static::$pathInfo = static::preparePathInfo(); static::$segments = explode('/', trim(static::$pathInfo, '/')); }
public static function find_by_sql($sql = "") { $instance = new static(); $object_array = array(); $sql = $instance->query($sql); if ($sql->execute()) { while ($row = $sql->fetch(\PDO::FETCH_ASSOC)) { $object_array[] = self::instantiate($row); } if ($object_array) { return $object_array; } else { return false; } } }
/** * Find a model by its primary key. * * @param string $id * @param array $columns * @return Model */ public static function find($id, $columns = array('*')) { $model = new static(); return $model->query()->where(static::$key, '=', $id)->first($columns); }
public static function delete($text) { static::$query = null; }
/** * Get all of the models from the database. * * @param array $columns * @return Collection */ public static function all() { $instance = new static(); return $instance->query()->all(); }
public static function find_by_sql($sql = "") { $instance = new static(); //$object_array =[]; $object_array = array(); $sql = $instance->query($sql); if ($sql->execute()) { while ($row = $sql->fetchAll(\PDO::FETCH_KEY_PAIR)) { $object_array[] = $row; } if ($object_array) { return $object_array; } else { return false; } } }
/** * Reset the class variables to null. */ public static function reset() { static::$query = null; static::$post = null; static::$properties = null; static::$server = null; static::$cookies = null; static::$files = null; static::$headers = null; static::$method = null; static::$pathInfo = null; static::$requestUri = null; static::$requestPath = null; static::$basePath = null; static::$baseUrl = null; }
/** * Find a model by its primary key. * * @param string $id * @param array $columns * @return Model */ public static function find($id, $columns = array('*')) { $model = new static(); $query = $model->query()->where(static::$key, '=', $id); list($query, $columns) = $model->before_find($query, $columns); $result = $query->take(1)->first($columns); $result = $model->after_find($result); if (count($result) > 0) { return $model->is_new(false)->fill($result); } return null; }
/** * Старт маршрутизации */ public static function start() { if (static::$start) { return false; } else { static::$start = true; } static::$record = true; static::$host = Request::host(); static::$path = Request::path(); static::$query = Request::query(); static::$method = Request::method(); if (preg_match('#^/index.php#i', static::$path)) { Error::e404(); } if (preg_match('#^/public/#i', static::$path)) { Error::e404(); } static::running(); if (!static::$found) { if (mb_substr(static::$path, -1, 1) != '/') { $extension = pathinfo(static::$path, PATHINFO_EXTENSION); if ($extension == "") { static::$path .= "/"; static::running(); if (static::$found) { Redirect::r302(static::$path . (static::$query != '' ? '?' . static::$query : '')); } } } } static::$record = false; if (static::$found) { static::render(); } else { Error::e404(); } }
/** * Update a model instance in the database. * * @param mixed $id * @param array $attributes * @return int */ public static function update($id, $attributes) { $model = new static(array(), true); $model->fill($attributes); if (static::$timestamps) { $model->timestamp(); } return $model->query()->where($model->key(), '=', $id)->update($model->attributes); }
/** * Update a model instance in the database. * * @param mixed $id * @param array $attributes * @return int */ public static function update($id, $attributes) { $model = new static(array(), true); if (static::$timestamps) { $attributes['updated_at'] = new \DateTime(); } return $model->query()->where($model->key(), '=', $id)->update($attributes); }
public static function translate($string, array $params = null, $package = null) { static::$instance or static::$instance = static::$di->getShared('i18n'); return static::$instance->query($string, $params, $package); }