本文整理汇总了PHP中Query::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::table方法的具体用法?PHP Query::table怎么用?PHP Query::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: paginate
public static function paginate($page = 1, $perpage = 10)
{
$query = Query::table(static::table());
$count = $query->count();
$results = $query->take($perpage)->skip(($page - 1) * $perpage)->sort('title')->get();
return new Paginator($results, $count, $page, $perpage, Uri::to('admin/companies'));
}
示例2: __callStatic
public static function __callStatic($method, $arguments)
{
$obj = Query::table(static::table())->apply(get_called_class());
if (method_exists($obj, $method)) {
return call_user_func_array(array($obj, $method), $arguments);
}
}
示例3: account
private static function account($settings)
{
$account = $settings['account'];
$database = $settings['database'];
$query = Query::table($database['prefix'] . 'users', static::$connection);
$query->insert(array('username' => $account['username'], 'password' => Hash::make($account['password']), 'email' => $account['email'], 'real_name' => 'Administrator', 'bio' => 'The bouse', 'status' => 'active', 'role' => 'administrator'));
}
示例4: paginate
public static function paginate($page = 1, $perpage = 10)
{
$query = Query::table(static::table());
$count = $query->count();
$results = $query->take($perpage)->skip(($page - 1) * $perpage)->sort('date', 'desc')->get();
return new Paginator($results, $count, $page, $perpage, url('comments'));
}
示例5: paginate
public static function paginate($page = 1, $perpage = 10)
{
$query = Query::table(static::table());
$count = $query->count();
$results = $query->take($perpage)->skip(($page - 1) * $perpage)->sort('real_name', 'desc')->get();
return new Paginator($results, $count, $page, $perpage, Uri::to('users'));
}
示例6: up
public function up()
{
$table = Base::table('meta');
if ($this->has_table($table)) {
if (!Query::table($table)->where('key', '=', 'comment_notifications')->count()) {
Query::table($table)->insert(array('key' => 'comment_notifications', 'value' => 0));
}
}
}
示例7: up
public function up()
{
$table = Base::table('categories');
if ($this->has_table($table)) {
if (!Query::table($table)->count()) {
Query::table($table)->insert(array('title' => 'Uncategorised', 'slug' => 'uncategorised', 'description' => 'Ain\'t no category here.'));
}
}
}
示例8: search
public static function search($term, $page = 1, $per_page = 10)
{
$query = Query::table(Base::table('posts'));
$query->join(Base::table('wtfsearch'), Base::table('posts.id'), '=', Base::table('wtfsearch.post_id'));
$query->left_join(Base::table('users'), Base::table('users.id'), '=', Base::table('posts.author'))->where(Base::table('posts.status'), '=', 'published')->where(Base::table('wtfsearch.meta_value'), 'like', '%' . $term . '%');
$query->group(Base::table('posts.id'));
$total = $query->count();
$posts = $query->take($per_page)->skip(--$page * $per_page)->get(array(Base::table('posts.*'), Base::table('users.id as author_id'), Base::table('users.bio as author_bio'), Base::table('users.real_name as author_name')));
return array($total, $posts);
}
示例9: get_posts_with_tag
/**
* Returns an array of ids for posts that have the specified tag
*
* @param string
* @return array
*/
function get_posts_with_tag($tag)
{
$tag_ext = Extend::where('key', '=', 'post_tags')->get();
$tag_id = $tag_ext[0]->id;
$prefix = Config::db('prefix', '');
$posts = array();
foreach (Query::table($prefix . 'post_meta')->where('extend', '=', $tag_id)->where('data', 'LIKE', '%' . $tag . '%')->get() as $meta) {
$posts[] = $meta->post;
}
return array_unique($posts);
}
示例10: up
public function up()
{
$table = Base::table('meta');
if ($this->has_table($table)) {
if (!Query::table($table)->where('key', '=', 'dashboard_page')->count()) {
Query::table($table)->insert(array('key' => 'dashboard_page', 'value' => 'panel'));
} else {
Query::table($table)->where('key', '=', 'dashboard_page')->update(array('value' => 'panel'));
}
}
}
示例11: up
public function up()
{
$table = Base::table('meta');
if ($this->has_table($table)) {
if (!Query::table($table)->where('key', '=', 'show_all_posts')->count()) {
Query::table($table)->insert(array('key' => 'show_all_posts', 'value' => 0));
} else {
Query::table($table)->where('key', '=', 'show_all_posts')->update(array('value' => 0));
}
}
}
示例12: renew
public static function renew()
{
$version = static::touch();
$today = date('Y-m-d H:i:s');
$table = Base::table('meta');
Query::table($table)->where('key', '=', 'last_update_check')->update(array('value' => $today));
Query::table($table)->where('key', '=', 'update_version')->update(array('value' => $version));
// reload database metadata
foreach (Query::table($table)->get() as $item) {
$meta[$item->key] = $item->value;
}
Config::set('meta', $meta);
}
示例13: migrations
public static function migrations()
{
$current = Config::meta('current_migration');
$migrate_to = Config::migrations('current');
$migrations = new Migrations($current);
$table = Base::table('meta');
if (is_null($current)) {
$number = $migrations->up($migrate_to);
Query::table($table)->insert(array('key' => 'current_migration', 'value' => $number));
} else {
if ($current < $migrate_to) {
$number = $migrations->up($migrate_to);
Query::table($table)->where('key', '=', 'current_migration')->update(array('value' => $number));
}
}
}
示例14: up
public function up()
{
$table = Base::table('pagetypes');
if (!$this->has_table($table)) {
$sql = "CREATE TABLE IF NOT EXISTS `" . $table . "` (\n\t\t\t\t`key` varchar(32) NOT NULL,\n\t\t\t\t`value` varchar(32) NOT NULL\n\t\t\t) ENGINE=InnoDB";
DB::ask($sql);
Query::table($table)->insert(array('key' => 'all', 'value' => 'All Pages'));
}
$table2 = Base::table('extend');
if (!$this->has_table_column($table2, 'pagetype')) {
$sql2 = "ALTER TABLE `" . $table2 . "` ADD `pagetype` VARCHAR(140) NOT NULL DEFAULT 'all' AFTER `type`";
DB::ask($sql2);
}
$table3 = Base::table('pages');
if (!$this->has_table_column($table3, 'pagetype')) {
$sql2 = "ALTER TABLE `" . $table3 . "` ADD `pagetype` VARCHAR(140) NOT NULL DEFAULT 'all' AFTER `slug`";
DB::ask($sql2);
}
}
示例15: company_count
function company_count()
{
return Query::table(Base::table('posts'))->where('company', '=', company_id())->where('status', '=', 'published')->count();
}