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


PHP Database::select方法代码示例

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


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

示例1: getEquip

function getEquip()
{
    $db = new Database();
    $link = $db->connect();
    $result = $db->select($link, 'equip_type');
    return $result;
}
开发者ID:xolodok373,项目名称:tit.biz,代码行数:7,代码来源:crudModel.php

示例2: populateSearchIndex

 /**
  * Populates the search index with content from all pages
  */
 protected function populateSearchIndex()
 {
     $res = $this->db->select('page', 'MAX(page_id) AS count');
     $s = $this->db->fetchObject($res);
     $count = $s->count;
     $this->output("Rebuilding index fields for {$count} pages...\n");
     $n = 0;
     $fields = array_merge(Revision::selectPageFields(), Revision::selectFields(), Revision::selectTextFields());
     while ($n < $count) {
         if ($n) {
             $this->output($n . "\n");
         }
         $end = $n + self::RTI_CHUNK_SIZE - 1;
         $res = $this->db->select(['page', 'revision', 'text'], $fields, ["page_id BETWEEN {$n} AND {$end}", 'page_latest = rev_id', 'rev_text_id = old_id'], __METHOD__);
         foreach ($res as $s) {
             try {
                 $title = Title::makeTitle($s->page_namespace, $s->page_title);
                 $rev = new Revision($s);
                 $content = $rev->getContent();
                 $u = new SearchUpdate($s->page_id, $title, $content);
                 $u->doUpdate();
             } catch (MWContentSerializationException $ex) {
                 $this->output("Failed to deserialize content of revision {$s->rev_id} of page " . "`" . $title->getPrefixedDBkey() . "`!\n");
             }
         }
         $n += self::RTI_CHUNK_SIZE;
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:rebuildtextindex.php

示例3: version_move

 public function version_move($table, $model, $id, $sid, $type)
 {
     if (!is_numeric($id)) {
         throw new Exception("Must pass subject id", 1);
     }
     if (!is_numeric($sid)) {
         throw new Exception("Must pass target id", 1);
     }
     if ($id == $sid) {
         throw new Exception("Subject and target cannot be the same", 1);
     }
     $types = array('move_to_last_child', 'move_to_first_child', 'move_to_next_sibling', 'move_to_prev_sibling');
     if (!in_array($type, $types)) {
         throw new Exception("Must pass move type", 1);
     }
     $db = new Database();
     $page_id = $db->select('page_id')->from($table)->where('id', $id)->get()->current()->page_id;
     $page_sid = $db->select('page_id')->from($table)->where('id', $sid)->get()->current()->page_id;
     self::version_position_table($table);
     $id = $db->select('id')->from($table)->where('page_id', $page_id)->get()->current()->id;
     $sid = $db->select('id')->from($table)->where('page_id', $page_sid)->get()->current()->id;
     $id_node = ORM::factory($model, $id);
     $item = ORM::factory($model, $sid);
     $item->{$type}($id_node);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:25,代码来源:versions_helper.php

示例4: testDeleteAll

 public function testDeleteAll()
 {
     $users = $this->database->select(User::class);
     $this->database->delete($users);
     $users = $this->database->select(User::class);
     $this->assertEquals(0, count($users));
 }
开发者ID:re222dv,项目名称:1DV408-Project,代码行数:7,代码来源:DatabaseE2E.php

示例5: insert

 /**
  * undocumented function
  *
  * @param string $target 
  * @param string $copy_left_from 
  * @param string $left_offset 
  * @param string $level_offset 
  * @return void
  * @author Andy Bennett
  */
 protected function insert($target, $copy_left_from, $left_offset, $level_offset)
 {
     $db = new Database();
     $obj_id = $db->select($this->parent_model . '_' . $this->primary_key)->from($this->table_name)->where('id', $target)->get()->current()->{$this->parent_model . '_' . $this->primary_key};
     versions_helper::version_position_table($this->table_name, $this->version);
     $target_id = $db->select($this->primary_key)->from($this->table_name)->where($this->parent_model . '_' . $this->primary_key, $obj_id)->get()->current()->{$this->primary_key};
     return parent::insert($target_id, $copy_left_from, $left_offset, $level_offset);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:18,代码来源:Versions_ORM_MPTT_Position.php

示例6: getMainElements

 public static function getMainElements($type)
 {
     $db = new Database();
     if ($type === "boards") {
         return $db->select('SELECT id, ownerid, catid, name, picture, updated' . ' FROM boards ORDER BY id DESC LIMIT 3');
     } else {
         if ($type === "products") {
             return $db->select('SELECT id, ownerid, catid, name, picture, price, source' . ' FROM products ORDER BY id DESC LIMIT 3');
         }
     }
 }
开发者ID:OHDMax,项目名称:OHDM-SDC,代码行数:11,代码来源:elementprovider.php

示例7: get

 /**
  * 取得数据,支持批量取
  * @param string/array $key
  * @return mixed
  */
 public function get($key)
 {
     $key_map = array();
     if (is_array($key)) {
         $md5_key = array();
         foreach ($key as &$k) {
             $key_map[$this->prefix . $k] = $k;
             $k = $this->prefix . $k;
             $md5_key[] = md5($k);
         }
         $this->_handler->in('key', $md5_key);
     } else {
         $key_map[$this->prefix . $key] = $key;
         $key = $this->prefix . $key;
         $this->_handler->where('key', md5($key))->limit(1);
     }
     $rs = $this->_handler->select('key_string', 'value', 'number')->from($this->tablename)->and_where_open()->where('expire', 0)->or_where('expire', TIME, '>')->and_where_close()->get();
     if ($rs->count()) {
         if (is_array($key)) {
             $return = array();
             foreach ($rs as $data) {
                 $data_key = $key_map[$data['key_string']];
                 $return[$data_key] = $data['value'];
                 if ('' === $data['value']) {
                     $return[$data_key] = $data['number'];
                 } else {
                     $this->_de_format_data($return[$data_key]);
                 }
             }
         } else {
             $return = $rs->current();
             if ('' === $return['value']) {
                 $return = $return['number'];
             } else {
                 $return = $return['value'];
                 $this->_de_format_data($return);
             }
         }
         if (IS_DEBUG) {
             Core::debug()->info($key, 'database cache hit key');
         }
         unset($rs);
         return $return;
     } else {
         if (IS_DEBUG) {
             Core::debug()->error($key, 'database cache mis key');
         }
     }
     return false;
 }
开发者ID:liuyu121,项目名称:myqee,代码行数:55,代码来源:database.class.php

示例8: get

 /**
  * 取得数据,支持批量取
  * @param string/array $key
  * @return mixed
  */
 public function get($key)
 {
     if (IS_DEBUG) {
         $key_bak = $key;
     }
     if (is_array($key)) {
         $this->_handler->in('key', array_map('md5', $key));
     } else {
         $this->_handler->where('key', md5($key))->limit(1);
     }
     $rs = $this->_handler->select('key', 'value', 'number')->from($this->tablename)->and_where_open()->where('expire', 0)->or_where('expire', TIME, '>')->and_where_close()->get();
     if ($rs->count()) {
         if (is_array($key)) {
             $return = array();
             foreach ($rs as $data) {
                 $return[$data['key']] = $data['value'];
                 if ('' === $data['value']) {
                     $return[$data['key']] = $data['number'];
                 } else {
                     if ($this->_compress) {
                         //启用数据压缩
                         $return[$data['key']] = gzuncompress($data['value']);
                     }
                     $return[$data['key']] = @unserialize($return);
                 }
             }
         } else {
             $return = $rs->current();
             if ('' === $return['value']) {
                 $return = $return['number'];
             } else {
                 $return = $return['value'];
                 if ($this->_compress) {
                     //启用数据压缩
                     $return = gzuncompress($return);
                 }
                 $return = @unserialize($return);
             }
         }
         if (IS_DEBUG) {
             Core::debug()->info($key_bak, 'database cache hit key');
         }
         return $return;
     } else {
         if (IS_DEBUG) {
             Core::debug()->error($key_bak, 'database cache mis key');
         }
     }
     return false;
 }
开发者ID:google2013,项目名称:myqeecms,代码行数:55,代码来源:Database.class.php

示例9: gsms

 /**
  * This method will get the IDS of the GSMs we want to filter by
  * 
  * This should cause no problems with doubling up on relaitonships as it creates its own db object, 
  * then just does a check against paper_id with out requiring a new relationship
  * 
  * @param array $values an array of selected gsms 'ranges' that come in the form of '100-150' 
  */
 public function gsms($values)
 {
     // create a new db object so we dont screw with the relationship on the search.
     $db = new Database();
     $db->select('paper_id')->from('collections')->join('pigments', 'collections.id', 'pigments.collection_id')->join('sheets', 'pigments.id', 'sheets.pigment_id')->join('gsms', 'sheets.id', 'gsms.sheet_id')->groupby('paper_id');
     // loop through each of the values (100-150), break them apart into a min/max and then do a between
     foreach ($values as $value) {
         $value = explode('-', $value);
         if (isset($value[0]) && isset($value[1]) && $value[0] < $value[1]) {
             $db->orwhere('gsms.name BETWEEN', "'" . $value[0] . "' AND '" . $value[1] . "'", false);
         }
     }
     $result = $db->get();
     $results = $result->result_array(false);
     // loop through each of the resultsm put the paper_ids into a cleaned array then add it to the searches params
     $papers = array();
     foreach ($results as $result) {
         $papers[] = $result['paper_id'];
     }
     if (count($papers)) {
         $this->db->in('papers.id', $papers);
         // note how this is $this->db :: ie hits the searches object to filter the papers by
     } else {
         $this->db->where('papers.id', '0');
         /// if there are no paper with that gsm, force the main query to return no results.
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:35,代码来源:Search_Papers.php

示例10: isAuthenticated

 public static function isAuthenticated()
 {
     //TODO
     //look if Token is present in $_Session
     Session::get('UserID') ? $auth = 'TRUE' : ($auth = 'FALSE');
     if ($auth === 'TRUE') {
         return TRUE;
     } else {
         if (isset($_COOKIE["RemembeR"])) {
             $db = new Database();
             //Get TOKEN from $_COOKIE
             //hash(Token) and compare with hashed Tokens in the Database
             $userdata['tokenhash'] = hash('sha1', $_COOKIE["RemembeR"]);
             echo $userdata['tokenhash'];
             $arr = $db->select("SELECT id, tokenhash FROM users WHERE tokenhash = :tokenhash LIMIT 1", $userdata);
             var_dump($arr);
             if (sizeof($arr[0]['id']) !== 0) {
                 //Set 'UserID' in Session
                 Session::set('UserID', $arr[0]['id']);
                 //Renew Cookie
                 $token = hash("md5", $arr[0]['id'] . Session::get('ID'));
                 $userdata['id'] = $arr[0]['id'];
                 $userdata['tokenhash'] = hash("sha1", $token);
                 $db->update("users", $userdata, "id = :id");
                 setcookie("RemembeR", $token, time() + 259200, "/", "studi.f4.htw-berlin.de", false, true);
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
开发者ID:OHDMax,项目名称:OHDM-SDC,代码行数:31,代码来源:authentication.php

示例11: copyExactMatch

 function copyExactMatch($srcTable, $dstTable, $copyPos)
 {
     $numRowsCopied = 0;
     $srcRes = $this->dbw->select($srcTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     $dstRes = $this->dbw->select($dstTable, '*', ['log_timestamp' => $copyPos], __METHOD__);
     if ($srcRes->numRows()) {
         $srcRow = $srcRes->fetchObject();
         $srcFields = array_keys((array) $srcRow);
         $srcRes->seek(0);
         $dstRowsSeen = [];
         # Make a hashtable of rows that already exist in the destination
         foreach ($dstRes as $dstRow) {
             $reducedDstRow = [];
             foreach ($srcFields as $field) {
                 $reducedDstRow[$field] = $dstRow->{$field};
             }
             $hash = md5(serialize($reducedDstRow));
             $dstRowsSeen[$hash] = true;
         }
         # Copy all the source rows that aren't already in the destination
         foreach ($srcRes as $srcRow) {
             $hash = md5(serialize((array) $srcRow));
             if (!isset($dstRowsSeen[$hash])) {
                 $this->dbw->insert($dstTable, (array) $srcRow, __METHOD__);
                 $numRowsCopied++;
             }
         }
     }
     return $numRowsCopied;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:30,代码来源:upgradeLogging.php

示例12: display

 public static function display()
 {
     $messages = "";
     if ($_POST['cc_form'] === 'add-group') {
         $group = $_POST['group'];
         $rows = Database::select('users', 'name', array('name = ? AND type = ?', $group, 'group'), null, 1)->fetch(PDO::FETCH_ASSOC);
         if (!empty($rows)) {
             $messages .= Message::error(__('admin', 'group-in-use'));
         } else {
             $row = DB::select('users', array('data'), array('users_id = ?', $_GET['parent']))->fetch(PDO::FETCH_ASSOC);
             $inheritance = unserialize($row['data']);
             $inheritance = $inheritance['permissions'];
             $result = Database::insert('users', array('name' => filter('admin_add_group_name', $group), 'type' => 'group', 'group' => '-1', 'data' => serialize(filter('admin_add_group_data', array('permissions' => $inheritance)))));
             if ($result === 1) {
                 $messages .= Message::success(__('admin', 'group-added'));
             }
         }
     }
     $form = new Form('self', 'post', 'add-group');
     $form->startFieldset(__("admin", 'group-information'));
     $form->addInput(__('admin', 'group-name'), 'text', 'group', self::get('group'));
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->addSelectList(__('admin', 'inherit-permissions'), 'parent', $groups);
     plugin('admin_add_group_custom_fields', array(&$form));
     $form->addSubmit('', 'add-group', __('admin', 'add-group'));
     $form->endFieldset();
     plugin('admin_add_group_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(__('admin', 'add-group'), $messages . $form);
 }
开发者ID:alecgorge,项目名称:TopHat,代码行数:33,代码来源:add-group.php

示例13: getUserBySession

 function getUserBySession($userID)
 {
     $db = new Database();
     $query = "SELECT * FROM users  WHERE user_id='{$userID}' ";
     $arrayUser = $db->select($query);
     return $arrayUser;
 }
开发者ID:loi219,项目名称:Shared-library,代码行数:7,代码来源:GetUser.php

示例14: index

 public function index($page = 1)
 {
     $db = new Database();
     // You can assign anything variable to a view by using standard OOP
     // methods. In my welcome view, the $title variable will be assigned
     // the value I give it here.
     $this->template->title = 'Welcome to YAG demo!';
     $grid = Grid::factory()->set('display_head', true)->set('display_foot', true)->set('display_body', true)->set('table_attributes', array('id' => 'demo_table_1', 'width' => '100%'));
     $grid->CheckboxField('id')->set('title', 'ID')->set('checked', array(2, 3, 4, 6, 9))->set('sortable', true)->set('foot', form::checkbox('checkall', 'yes', false, "onclick=\"check_all('id[]');\"") . form::dropdown('action', array('edit' => 'Edit', 'delete' => 'Delete'), 'edit') . form::submit('submit', 'OK'))->set('extra', array("onclick" => "checkbox_check('id[]')"));
     $grid->TextField('id')->set('title', 'ID')->set('sortable', true);
     $grid->TextField('text')->set('title', 'Text')->set('sortable', true);
     $grid->DateField('date')->set('title', 'Date')->set('format', 'Y-m-d')->set('sortable', true);
     $grid->ActionField()->set('title', 'Action')->add_action('edit', 'id', 'Edit', 'http://www.path.to/my/controller')->add_action('delete', 'id', 'Delete');
     $offset = (int) ($page - 1) * 10;
     $offset = $offset < 0 ? 0 : $offset;
     $order_field = 'id';
     $order_direction = 'asc';
     if ($this->input->get('order_by') and $grid->field_exists($order_field, true)) {
         $order_field = $this->input->get('order_by');
     }
     if ($this->input->get('order_direction') and in_array(strtoupper($this->input->get('order_direction')), array('ASC', 'DESC'))) {
         $order_direction = strtoupper($this->input->get('order_direction'));
     }
     $data = $db->select($grid->get_fields(true))->from('demotable')->limit(10)->offset($offset)->orderby($order_field, $order_direction)->get();
     $count = $db->query('SELECT FOUND_ROWS() AS rows;')->current();
     $this->pagination = new Pagination(array('total_items' => $count->rows, 'items_per_page' => 10));
     $grid->set('extra_row_foot', '<td colspan="' . count($grid->fields) . '">' . $this->pagination->render() . '</td>');
     $grid->set('data', $data);
     $html = $grid->render();
     // Get Javascript for checkbox gimmicks
     $this->template->checkall_js = $grid->render_js('checkall');
     $this->template->content = $html;
 }
开发者ID:ThorstenS,项目名称:YAG,代码行数:33,代码来源:yagdemo.php

示例15: get

 /**
  * Retrieve a value from the variables.
  * @param string $name Variable name
  * @param variant $default Return value if no variable exists with this name.
  * @param boolean $caching Use the Kohana cache to retrieve the value?
  */
 public static function get($name, $default = false, $caching = true)
 {
     $value = null;
     if ($caching) {
         $cache = Cache::instance();
         // get returns null if no value
         $value = $cache->get("variable-{$name}");
     }
     if ($value === null) {
         $db = new Database();
         $r = $db->select('value')->from('variables')->where('name', $name)->get()->result_array(false);
         if (count($r)) {
             $array = json_decode($r[0]['value']);
             $value = $array[0];
             if ($caching) {
                 $cache->set("variable-{$name}", $value, array('variables'));
             }
         }
     }
     if ($value !== null) {
         return $value;
     } else {
         return $default;
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:31,代码来源:variable.php


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