当前位置: 首页>>代码示例>>PHP>>正文


PHP Table::select方法代码示例

本文整理汇总了PHP中Table::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::select方法的具体用法?PHP Table::select怎么用?PHP Table::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Table的用法示例。


在下文中一共展示了Table::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Get menu
  *
  * @param string $category Category name
  */
 public static function get($category = '')
 {
     // Get menu table
     $menu = new Table('menu');
     // Display view
     View::factory('box/menu/views/frontend/index')->assign('items', $menu->select('[category="' . $category . '"]', 'all', null, array('id', 'name', 'link', 'target', 'order', 'category'), 'order', 'ASC'))->assign('uri', Uri::segments())->assign('defpage', Option::get('defaultpage'))->display();
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:12,代码来源:menu.plugin.php

示例2: select

 public function select()
 {
     $select = parent::select();
     $select->from($this, array('id', 'name'));
     if (!$this->isAdmin()) {
         $select->where('public = 1');
     }
     $select->setIntegrityCheck(false)->joinLeft('gallery_info', 'gallery_info.file_id = files.id', array('title', 'description'));
     return $select;
 }
开发者ID:html,项目名称:PI,代码行数:10,代码来源:GalleryModel.php

示例3: get

 /**
  * Get slider
  *
  * @param string $category Category name
  */
 public static function get($category = '')
 {
     if ($category == 'default') {
         $category = '';
     }
     // Get slider table
     $slider = new Table('slider');
     // Display view
     View::factory('slider/views/frontend/index')->assign('items', $slider->select('[category="' . $category . '"]', 'all', null, null, 'order', 'ASC'))->assign('uri', Uri::segments())->assign('defpage', Option::get('defaultpage'))->display();
 }
开发者ID:cmroanirgo,项目名称:monstra-slider,代码行数:15,代码来源:slider.plugin.php

示例4: _realRefresh

 protected function _realRefresh()
 {
     $where = $this->_getWhereQuery();
     $row = $this->_table->select()->whereClauses($where)->fetchRow();
     if (null === $row) {
         throw new DataObjectException('Cannot refresh row as parent is missing');
     }
     $this->exchangeArray($row->getArrayCopy());
     $this->_cleanData = [];
 }
开发者ID:shen2,项目名称:mdo,代码行数:10,代码来源:TableTrait.php

示例5: init

 /**
  * init
  *
  * @return self
  */
 public function init()
 {
     $adapter = new \Bluz\Grid\Source\SelectSource();
     $musician = Table::select();
     $adapter->setSource($musician);
     $this->setAdapter($adapter);
     $this->setAllowOrders(['title', 'id', 'created', 'updated']);
     $this->setAllowFilters(['id', 'nickname', 'image', 'music_id', 'group', 'concert_date']);
     return $this;
 }
开发者ID:Kit-kat1,项目名称:bluz,代码行数:15,代码来源:Grid.php

示例6: __construct

 /**
  * Construct
  */
 protected function __construct()
 {
     // Get plugins Table
     $plugins = new Table('plugins');
     // Select all plugins
     $records = $plugins->select(null, 'all', null, array('location', 'status', 'priority'), 'priority', 'ASC');
     // Now include plugins from $records plugins array
     // If plugin is active then load it to the system.
     foreach ($records as $record) {
         if ($record['status'] == 'active') {
             include_once ROOT . DS . $record['location'];
         }
     }
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:17,代码来源:Plugin.php

示例7: __construct

 /**
  * Construct
  */
 protected function __construct($locale)
 {
     // Redefine arguments
     $locale = (string) $locale;
     // Get lang table for current locale
     $lang_table = Cache::get('i18n', $locale);
     // If lang_table is empty then create new
     if (!$lang_table) {
         // Get plugins Table
         $plugins = new Table('plugins');
         // Get all plugins
         $records = $plugins->select(null, 'all', null, array('location', 'priority'), 'priority', 'ASC');
         // Init var
         $lang_table = array();
         // Loop through each installed plugin
         foreach ($records as $record) {
             if (is_dir(ROOT . DS . dirname($record['location']) . DS . 'languages')) {
                 // Init var
                 $t = array();
                 // Check lang file
                 if (file_exists(ROOT . DS . dirname($record['location']) . DS . 'languages' . DS . $locale . '.lang.php')) {
                     // Merge the language strings into the sub table
                     $t = array_merge($t, include ROOT . DS . dirname($record['location']) . DS . 'languages' . DS . $locale . '.lang.php');
                 }
                 // Append the sub table, preventing less specific language files from overloading more specific files
                 $lang_table += $t;
             }
         }
         // Save lang table for current locale
         Cache::put('i18n', $locale, $lang_table);
         // Update dictionary
         I18n::$dictionary = $lang_table;
     }
     // Update dictionary
     I18n::$dictionary = $lang_table;
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:39,代码来源:I18n.php

示例8: getPages

 /**
  * Get pages
  */
 public static function getPages()
 {
     // Init vars
     $pages_array = array();
     $count = 0;
     // Get pages table
     $pages = new Table('pages');
     // Get Pages List
     $pages_list = $pages->select('[slug!="error404" and status="published"]');
     foreach ($pages_list as $page) {
         $pages_array[$count]['title'] = Html::toText($page['title']);
         $pages_array[$count]['meta_title'] = !empty($page['meta_title']) ? Html::toText($page['meta_title']) : $page['title'];
         $pages_array[$count]['parent'] = $page['parent'];
         $pages_array[$count]['date'] = $page['date'];
         $pages_array[$count]['author'] = $page['author'];
         $pages_array[$count]['slug'] = $page['slug'] == Option::get('defaultpage') ? '' : $page['slug'];
         if (isset($page['parent'])) {
             $c_p = $page['parent'];
         } else {
             $c_p = '';
         }
         if ($c_p != '') {
             $_page = $pages->select('[slug="' . $page['parent'] . '"]', null);
             if (isset($_page['title'])) {
                 $_title = $_page['title'];
             } else {
                 $_title = '';
             }
             $pages_array[$count]['sort'] = $_title . ' ' . $page['title'];
         } else {
             $pages_array[$count]['sort'] = $page['title'];
         }
         $_title = '';
         $count++;
     }
     // Sort pages
     $_pages_list = Arr::subvalSort($pages_array, 'sort');
     // return
     return $_pages_list;
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:43,代码来源:pages.plugin.php

示例9: select

<?php

class Table
{
    public static function select()
    {
        $table = get_called_class();
        $table = strtolower($table);
        return "SELECT * FROM {$table}";
    }
}
class Produtos extends Table
{
}
echo Table::select();
echo "\n";
echo Produtos::select();
?>


开发者ID:neves,项目名称:php,代码行数:18,代码来源:01_get_called_class.php

示例10: rtrim

define('DS', DIRECTORY_SEPARATOR);
define('ROOT', rtrim(str_replace(array('admin'), array(''), dirname(__FILE__)), '\\/'));
define('BACKEND', true);
define('MONSTRA_ACCESS', true);
// Load Monstra engine _init.php file
require_once ROOT . DS . 'engine' . DS . '_init.php';
// Errors var when users login failed
$login_error = '';
// Get users Table
$users = new Table('users');
// Admin login
if (Request::post('login_submit')) {
    if (Cookie::get('login_attempts') && Cookie::get('login_attempts') >= 5) {
        $login_error = __('You are banned for 10 minutes. Try again later', 'users');
    } else {
        $user = $users->select("[login='" . trim(Request::post('login')) . "']", null);
        if (count($user) !== 0) {
            if ($user['login'] == Request::post('login')) {
                if (trim($user['password']) == Security::encryptPassword(Request::post('password'))) {
                    if ($user['role'] == 'admin' || $user['role'] == 'editor') {
                        Session::set('admin', true);
                        Session::set('user_id', (int) $user['id']);
                        Session::set('user_login', (string) $user['login']);
                        Session::set('user_role', (string) $user['role']);
                        Session::set('user_email', (string) $user['email']);
                        Request::redirect('index.php');
                    }
                } else {
                    $login_error = __('Wrong <b>username</b> or <b>password</b>', 'users');
                    if (Cookie::get('login_attempts')) {
                        if (Cookie::get('login_attempts') < 5) {
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:31,代码来源:index.php

示例11: hasEvents

 /**
  * Returns true if location has events assigned
  *
  * @param  int  $id  Location ID to check
  *
  * @return bool
  *
  */
 public static function hasEvents($id)
 {
     $events = new Table('events');
     return sizeof($events->select('[location=' . $id . ' and deleted=0]', 'all')) > 0;
 }
开发者ID:devmount-monstra,项目名称:events,代码行数:13,代码来源:repository.locations.php

示例12: getList

 /**
  * Get configured list of events
  *
  * @param string  $time
  * @param string  $count
  * @param string  $order
  * @param string  $groupby
  * @param bool    $is_archive
  *
  * @return array
  *
  */
 public static function getList($time, $count, $order, $groupby = '', $is_archive = false)
 {
     // get db table object
     $objects = self::getTable();
     // handle order
     $roworder = '';
     if (in_array(trim($order), array('ASC', 'DESC'))) {
         $roworder = trim($order);
     } else {
         $roworder = 'ASC';
     }
     // handle time
     $now = self::_getTime();
     switch ($time) {
         case 'future':
             $eventlist = $objects->select('[number(translate(timestamp_end,"-: ",""))>=' . $now . ' and status="published" and deleted=0]', 'all', null, null, 'timestamp', $roworder);
             break;
         case 'past':
             $eventlist = $objects->select('[number(translate(timestamp,"-: ",""))<' . $now . ' and status="published" and deleted=0]', 'all', null, null, 'timestamp', $roworder);
             break;
         case 'all':
         default:
             $eventlist = $objects->select('[status="published" and deleted=0]', 'all', null, null, 'timestamp', $roworder);
             break;
     }
     // handle count
     if (trim($count) != 'all') {
         if ($roworder == 'ASC') {
             $eventlist = array_slice($eventlist, 0, (int) $count);
         } else {
             $offset = count($eventlist) - (int) $count;
             $offset = $offset < 0 ?: $offset;
             $eventlist = array_slice($eventlist, $offset);
         }
     }
     // handle archive (remove events of category with flag (hidden_in_archive))
     if ($is_archive) {
         $categories = new Table('categories');
         $category_ids = array();
         foreach ($categories->select('[hidden_in_archive=1]', 'all', null, array('id')) as $category) {
             $category_ids[] = $category['id'];
         }
         foreach ($eventlist as $key => $event) {
             if (in_array($event['category'], $category_ids)) {
                 unset($eventlist[$key]);
             }
         }
     }
     // handle group by
     if ($groupby == 'year') {
         $eventlistyears = array();
         foreach ($eventlist as $event) {
             $year = date('Y', strtotime($event['timestamp']));
             $eventlistyears[$year][] = $event;
         }
         return $eventlistyears;
     }
     return $eventlist;
 }
开发者ID:devmount-monstra,项目名称:events,代码行数:71,代码来源:repository.events.php

示例13: main

 /**
  * Users admin
  */
 public static function main()
 {
     // Users roles
     $roles = array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users'));
     // Get uses table
     $users = new Table('users');
     if (Option::get('users_frontend_registration') === 'true') {
         $users_frontend_registration = true;
     } else {
         $users_frontend_registration = false;
     }
     if (Request::post('users_frontend_submit')) {
         if (Security::check(Request::post('csrf'))) {
             if (Request::post('users_frontend_registration')) {
                 $users_frontend_registration = 'true';
             } else {
                 $users_frontend_registration = 'false';
             }
             if (Option::update('users_frontend_registration', $users_frontend_registration)) {
                 Notification::set('success', __('Your changes have been saved.', 'users'));
             } else {
                 Notification::set('error', __('Your changes was not saved.', 'users'));
             }
             Request::redirect('index.php?id=users');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Add
             // -------------------------------------
             case "add":
                 if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
                     // Errors
                     $errors = array();
                     if (Request::post('register')) {
                         if (Security::check(Request::post('csrf'))) {
                             $user_login = trim(Request::post('login'));
                             $user_password = trim(Request::post('password'));
                             $user_email = trim(Request::post('email'));
                             if ($user_login == '') {
                                 $errors['users_empty_login'] = __('Required field', 'users');
                             }
                             if ($user_password == '') {
                                 $errors['users_empty_password'] = __('Required field', 'users');
                             }
                             if ($user_email == '') {
                                 $errors['users_empty_email'] = __('Required field', 'users');
                             }
                             if ($users->select("[login='" . $user_login . "']")) {
                                 $errors['users_this_user_already_exists'] = __('This user already exists', 'users');
                             }
                             if ($users->select("[email='" . $user_email . "']")) {
                                 $errors['users_this_email_already_exists'] = __('This email already exists', 'users');
                             }
                             if (count($errors) == 0) {
                                 if ($users->insert(array('login' => Security::safeName($user_login), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => Request::post('role')))) {
                                     Notification::set('success', __('New user have been registered.', 'users'));
                                 } else {
                                     Notification::set('error', __('New user was not registered.', 'users'));
                                 }
                                 Request::redirect('index.php?id=users');
                             }
                         } else {
                             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                         }
                     }
                     // Display view
                     View::factory('box/users/views/backend/add')->assign('roles', $roles)->assign('errors', $errors)->display();
                 } else {
                     Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
                 }
                 break;
                 // Edit
                 // -------------------------------------
             // Edit
             // -------------------------------------
             case "edit":
                 // Get current user record
                 $user = $users->select("[id='" . (int) Request::get('user_id') . "']", null);
                 if (isset($user['firstname'])) {
                     $user_firstname = $user['firstname'];
                 } else {
                     $user_firstname = '';
                 }
                 if (isset($user['lastname'])) {
                     $user_lastname = $user['lastname'];
                 } else {
                     $user_lastname = '';
                 }
                 if (isset($user['email'])) {
                     $user_email = $user['email'];
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:users.admin.php

示例14: Table

<?php

/* Example: Simple and Object Select Query */
/* Including the Class */
include_once 'lib/Database.php';
/* select a database table */
$test = new Table("test");
/* 1. Applying Simple Query */
$rows = $test->select("*");
/* Iterating Results */
foreach ($rows as $r) {
    /* Printing Data */
    echo "Simple Query Result: " . $r['name'] . '<br/>';
}
/* 2. Applying Object Query */
$rows = $test->selectObject("*");
/* Iterating Results */
while ($row = $rows->getAndNext()) {
    /* Printing Data */
    echo "Object Query Result: " . $row->name . '<br/>';
}
开发者ID:alinawaz,项目名称:crazyDatabase,代码行数:21,代码来源:Example.php

示例15: main

 /**
  * Pages admin function
  */
 public static function main()
 {
     $current_theme = Option::get('theme_site_name');
     $site_url = Option::get('siteurl');
     $templates_path = THEMES_SITE;
     $errors = array();
     $pages = new Table('pages');
     PagesAdmin::$pages = $pages;
     $users = new Table('users');
     $user = $users->select('[id=' . Session::get('user_id') . ']', null);
     // Page author
     if (!empty($user['firstname'])) {
         $author = empty($user['lastname']) ? $user['firstname'] : $user['firstname'] . ' ' . $user['lastname'];
     } else {
         $author = Session::get('user_login');
     }
     $author = Html::toText($author);
     // Status array
     $status_array = array('published' => __('Published', 'pages'), 'draft' => __('Draft', 'pages'));
     // Access array
     $access_array = array('public' => __('Public', 'pages'), 'registered' => __('Registered', 'pages'));
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Clone page
             // -------------------------------------
             case "clone_page":
                 if (Security::check(Request::get('token'))) {
                     // Generate rand page name
                     $rand_page_name = Request::get('name') . '_clone_' . date("Ymd_His");
                     // Get original page
                     $orig_page = $pages->select('[slug="' . Request::get('name') . '"]', null);
                     // Generate rand page title
                     $rand_page_title = $orig_page['title'] . ' [copy]';
                     // Clone page
                     if ($pages->insert(array('slug' => $rand_page_name, 'template' => $orig_page['template'], 'parent' => $orig_page['parent'], 'robots_index' => $orig_page['robots_index'], 'robots_follow' => $orig_page['robots_follow'], 'status' => $orig_page['status'], 'access' => isset($orig_page['access']) ? $orig_page['access'] : 'public', 'expand' => isset($orig_page['expand']) ? $orig_page['expand'] : '0', 'title' => $rand_page_title, 'meta_title' => $orig_page['meta_title'], 'description' => $orig_page['description'], 'keywords' => $orig_page['keywords'], 'tags' => $orig_page['tags'], 'date' => $orig_page['date'], 'author' => $orig_page['author']))) {
                         // Get cloned page ID
                         $last_id = $pages->lastId();
                         // Save cloned page content
                         File::setContent(STORAGE . DS . 'pages' . DS . $last_id . '.page.txt', File::getContent(STORAGE . DS . 'pages' . DS . $orig_page['id'] . '.page.txt'));
                         // Send notification
                         Notification::set('success', __('The page <i>:page</i> cloned.', 'pages', array(':page' => Security::safeName(Request::get('name'), '-', true))));
                     }
                     // Run add extra actions
                     Action::run('admin_pages_action_clone');
                     // Redirect
                     Request::redirect('index.php?id=pages');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Add page
                 // -------------------------------------
             // Add page
             // -------------------------------------
             case "add_page":
                 // Add page
                 if (Request::post('add_page') || Request::post('add_page_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         // Get parent page
                         if (Request::post('pages') == '0') {
                             $parent_page = '';
                         } else {
                             $parent_page = Request::post('pages');
                         }
                         // Validate
                         //--------------
                         if (trim(Request::post('page_name')) == '') {
                             $errors['pages_empty_name'] = __('Required field', 'pages');
                         }
                         if (trim(Request::post('page_title')) == '') {
                             $errors['pages_empty_title'] = __('Required field', 'pages');
                         }
                         if (count($pages->select('[slug="' . Security::safeName(Request::post('page_name'), '-', true) . '"]')) != 0) {
                             $errors['pages_exists'] = __('This page already exists', 'pages');
                         }
                         // Prepare date
                         if (Valid::date(Request::post('page_date'))) {
                             $date = strtotime(Request::post('page_date'));
                         } else {
                             $date = time();
                         }
                         if (Request::post('robots_index')) {
                             $robots_index = 'noindex';
                         } else {
                             $robots_index = 'index';
                         }
                         if (Request::post('robots_follow')) {
                             $robots_follow = 'nofollow';
                         } else {
                             $robots_follow = 'follow';
                         }
                         // If no errors then try to save
                         if (count($errors) == 0) {
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:pages.admin.php


注:本文中的Table::select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。