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


PHP SelectQuery::fetchAll方法代码示例

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


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

示例1: search

 public static function search(TableCtl $controller, $term, $filter = false)
 {
     $object = call_user_func(array(get_class($controller), 'getObject'));
     if (!$object) {
         return false;
     }
     $terms = preg_split('/[ ,]/', $term);
     if (!count($terms)) {
         return false;
     }
     //Check for results containing the word
     $search = array();
     foreach ($terms as $oneTerm) {
         $search[] = '`word` LIKE CONCAT("%", ?, "%")';
     }
     //Check for results with the exact word
     $search[] = '`word` IN (' . implode(', ', array_fill(0, count($terms), '?')) . ')';
     $search = '(' . implode(') OR (', $search) . ')';
     $params = array_merge(array($object->getSource()), $terms, $terms);
     $query = new SelectQuery(get_called_class());
     $query->field('DISTINCT `' . $object->getMeta('table') . '`.*')->leftJoin(get_class($controller), '`' . $object->getMeta('table') . '`.`' . $object->getMeta('id_field') . '` = `table_id`')->filter('`table` = ?')->filter($search)->order('`count` DESC, `sequence`');
     if ($filter) {
         if (is_array($filter)) {
             foreach ($filter as $one_fil) {
                 $query->filter($one_fil);
             }
         } else {
             $query->filter($filter);
         }
     }
     $result = $query->fetchAll($params);
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:33,代码来源:BackendSearch.obj.php

示例2: action_check_defines

 public function action_check_defines()
 {
     if (!Component::isActive('BackendError')) {
         return false;
     }
     $query = new SelectQuery('BackendError');
     $query->distinct()->field('query')->filter("`string` LIKE 'Undefined index: %'")->filter("`file` LIKE '%\\\\Render.obj.php(%) : eval()\\'d code'")->filter("`query` LIKE 'a_p_i/define/%'");
     return $query->fetchAll(array(), array('column' => 0));
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:9,代码来源:API.obj.php

示例3: action_display

 public function action_display($id)
 {
     $query = new SelectQuery('ContentRevision');
     $query->filter('`content_id` = :id')->order('`added` DESC');
     $revisions = $query->fetchAll(array(':id' => $id));
     $content = new ContentObj($id);
     if ($content->object) {
         $content->object->revisions = $revisions;
     } else {
         $content = false;
     }
     return $content;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:13,代码来源:ContentRevision.obj.php

示例4: read

 public function read($options = array())
 {
     $result = parent::read($options);
     if ($result) {
         $query = new SelectQuery('Assignment');
         $query->distinct()->field('`roles`.`name`')->leftJoin('Role', '`roles`.`id` = `assignments`.`role_id`')->filter("`assignments`.`access_type` = 'users'")->filter('`assignments`.`access_id` = :user_id OR `assignments`.`access_id` = 0')->order('`roles`.`name`');
         $roles = $query->fetchAll(array(':user_id' => $this->getMeta('id')), array('column' => 0));
         $roles = empty($roles) ? array() : $roles;
         if ($this->object) {
             $this->object->roles = $roles;
         }
         if ($this->array) {
             $this->array['roles'] = $roles;
         }
     }
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:17,代码来源:BackendUserObj.obj.php

示例5: getComments

 public static function getComments($table = false, $table_id = false, $limit = false)
 {
     $query = new SelectQuery('Comment');
     $query->field(array('`comments`.*, `backend_users`.`username`, `backend_users`.`email`'))->leftJoin('BackendUser', '`comments`.`user_id` = `backend_users`.`id`')->filter('`comments`.`active` = 1')->order('IF(`comments`.`in_reply_to` = 0, `comments`.`id`, `comments`.`in_reply_to`) DESC');
     $params = array();
     if ($table) {
         $query->filter('`comments`.`foreign_table` = :table');
         $params[':table'] = $table;
     }
     if ($table_id) {
         $query->filter('`comments`.`foreign_id` = :table_id');
         $params[':table_id'] = $table_id;
     }
     if ($limit) {
         $query->limit($limit);
     }
     return $query->fetchAll($params);
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:18,代码来源:Comment.obj.php

示例6: get

 public static function get($hook, $type = 'pre')
 {
     if (!BACKEND_WITH_DATABASE) {
         return false;
     }
     $params = array(':type' => $type, ':hook' => $hook);
     $query = new SelectQuery('Hook');
     $query->leftJoin('Component', array('`hooks`.`class` = `components`.`name`'))->filter('`hooks`.`hook` = :hook')->filter('`hooks`.`type` = :type')->filter('`hooks`.`active` = 1')->filter('`components`.`active` = 1');
     if (Controller::$area) {
         $query->filter('`global` = 1 OR `class` = :area');
         $params[':area'] = Controller::$area;
     }
     if (Controller::$view && Controller::$view->mode) {
         $query->filter('`mode` IN (:mode, \'*\')');
         $params[':mode'] = Controller::$view->mode;
     }
     $query->order('`sequence`');
     return $query->fetchAll($params);
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:19,代码来源:Hook.obj.php

示例7: getTagNames

 public static function getTagNames($table, $table_id = null)
 {
     if (is_null($table_id)) {
         if (!$table instanceof DBObject) {
             return false;
         }
         $table_id = $table->getMeta('id');
         $table = $table->getMeta('table');
     }
     $query = new SelectQuery('Tag');
     $query->field('`tags`.`id`, `tags`.`name`')->leftJoin('TagLink', array('`tags`.`id` = `tag_links`.`tag_id`'))->filter('`tags`.`foreign_table` = :table')->filter('`tag_links`.`foreign_id` = :id');
     $result = $query->fetchAll(array(':table' => $table, ':id' => $table_id), array('with_key' => true));
     if (!$result) {
         return $result;
     }
     foreach ($result as $key => $value) {
         $result[$key] = current($value);
     }
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:20,代码来源:Tag.obj.php

示例8: action_filter

 public function action_filter($pageId = 1)
 {
     $query = new SelectQuery('BackendRequest');
     $query->setFields(array('user_id', 'ip', 'user_agent', 'mode', 'request', 'query', 'COUNT(id) AS `occured`', 'MAX(`added`) AS `last_occured`'));
     $query->setGroup(array('user_id', 'ip', 'user_agent', 'mode', 'request', 'query'));
     $params = $queryFilter = array();
     $parameters = Controller::getVar('params');
     $sort = Controller::getVar('sort');
     if (!empty($parameters['userId'])) {
         $queryFilter[] = 'user_id = :userId';
         $params[':userId'] = $parameters['userId'];
     }
     if (!empty($parameters['query'])) {
         $queryFilter[] = "query LIKE('%{$parameters['query']}%')";
     }
     if (!empty($parameters['ip'])) {
         $queryFilter[] = "ip LIKE('%{$parameters['ip']}%')";
     }
     if (!empty($parameters['user_agent'])) {
         $queryFilter[] = "user_agent LIKE('%{$parameters['user_agent']}%')";
     }
     $query->filter($queryFilter);
     $count = 10;
     if (!empty($sort['field'])) {
         $query->setOrder(array($sort['field'] . '  ' . $sort['order']));
     }
     if ($pageId == 1) {
         $start = 0;
     } elseif ($pageId == 0) {
         $start = false;
         $count = false;
     } else {
         $start = floor(($pageId - 1) * $count);
     }
     $pager = array();
     if ($start === 'all') {
         $limit = 'all';
     } else {
         if ($start || $count) {
             $limit = "{$start}, {$count}";
         } else {
             $limit = false;
         }
     }
     $query->limit($limit);
     $items = $query->fetchAll($params);
     $totalItems = $query->getCount($params);
     $pager = '';
     if ($start || $count) {
         $pager = array('currentPage' => $pageId, 'itemCount' => count($items), 'itemTotal' => $totalItems, 'totalPages' => round(($totalItems - 1) / $count, 0));
     }
     $retArray['pager'] = $pager;
     $retArray['data'] = $items;
     $retArray['params'] = $parameters;
     $retArray['sort'] = $sort;
     return $retArray;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:57,代码来源:BackendRequest.obj.php

示例9: permissionHolders

 private static function permissionHolders($action = '*', $subject = '*', $subject_id = 0)
 {
     $result = false;
     $query = new SelectQuery('Permission');
     $params = array();
     if ($action != '*') {
         $query->filter("(`action` = :action OR `action` = '*')");
         $params[':action'] = $action;
     }
     if ($subject != '*') {
         $query->filter("(`subject` = :subject OR `subject` = '*')");
         $params[':subject'] = $subject;
     }
     if ($subject_id != '0') {
         $query->filter("(`subject_id` = :subject_id OR `subject_id` = 0)");
         $params[':subject_id'] = $subject_id;
     }
     $result = $query->fetchAll($params);
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:20,代码来源:GateKeeper.obj.php

示例10: getSitemap

 public static function getSitemap()
 {
     $query = new SelectQuery('Content');
     $query->filter('`active` = 1');
     $list = $query->fetchAll();
     return array('list' => $list, 'options' => array());
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:7,代码来源:Content.obj.php

示例11: get_permissions

 public function get_permissions($component = false)
 {
     $toret = new stdClass();
     //Base Permissions
     $parameters = array();
     $query = new SelectQuery('Permission');
     $query->distinct()->field(array('action', 'subject'))->filter('`active` = 1')->filter('`subject_id` = 0')->group('`subject`, `action` WITH ROLLUP');
     if ($component) {
         $query->filter('`subject` = :component');
         $parameters[':component'] = class_for_url($component);
     }
     $toret->base_perms = $query->fetchAll($parameters);
     //Roles
     $query = new SelectQuery('Role');
     $query->filter('`active` = 1');
     $toret->roles = $query->fetchAll();
     //Activated Permissions
     $parameters = array();
     $query = new SelectQuery('Permission', array('fields' => "CONCAT(`subject`, '::', `action`), GROUP_CONCAT(DISTINCT `role` ORDER BY `role`) AS `roles`"));
     $query->filter('`active` = 1')->filter('`subject_id` = 0')->filter("`role` != 'nobody'")->group('`subject`, `action`');
     if ($component) {
         $query->filter('`subject` = :component');
         $parameters[':component'] = class_for_url($component);
     }
     $permissions = $query->fetchAll($parameters, array('with_key' => 1));
     $toret->permissions = array();
     foreach ($permissions as $key => $value) {
         $toret->permissions[$key] = explode(',', current($value));
     }
     return $toret;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:31,代码来源:GateManager.obj.php


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