本文整理汇总了PHP中static::query方法的典型用法代码示例。如果您正苦于以下问题:PHP static::query方法的具体用法?PHP static::query怎么用?PHP static::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
/**
* getQuery
*
* @param bool $new
*
* @return Query
*/
public static function getQuery($new = false)
{
if (!static::$query || $new) {
static::$query = new Query();
}
return static::$query;
}
示例2: getQuery
/**
* 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;
}
示例3: getTicketByID
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;
}
}
示例4: findByAppId
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;
}
}
示例5: __construct
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;
}
示例6: init
/**
* 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, '/'));
}
示例7: find_by_sql
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;
}
}
}
示例8: find
/**
* 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);
}
示例9: delete
public static function delete($text)
{
static::$query = null;
}
示例10: all
/**
* Get all of the models from the database.
*
* @param array $columns
* @return Collection
*/
public static function all()
{
$instance = new static();
return $instance->query()->all();
}
示例11: find_by_sql
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;
}
}
}
示例12: reset
/**
* 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;
}
示例13: find
/**
* 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;
}
示例14: start
/**
* Старт маршрутизации
*/
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();
}
}
示例15: update
/**
* 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);
}