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


PHP PDO::tableName方法代码示例

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


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

示例1: prepareSQL

 /**
  * Returns generic SQL query that can be adaptated by child classes.
  * 
  * @version 0.1.5
  * @since 0.1.5
  * @param array $fields Fields to be selected.
  * @param bool $count Shows if the SQL should be generated for COUNT() variant.
  * @return string SQL query.
  */
 protected function prepareSQL($fields, $count = false)
 {
     $tables = array();
     // generates tables list for current qeury
     if (isset($this->filter)) {
         $tables = $this->filter->getTables();
     }
     // adds default table
     if (!in_array($this->table, $tables)) {
         $tables[] = $this->table;
     }
     // prepares tables names
     foreach ($tables as &$name) {
         $name = $this->db->tableName($name);
     }
     // WHERE clause
     if (isset($this->filter)) {
         $where = ' WHERE ' . $this->filter->__toString();
     } else {
         $where = '';
     }
     // ORDER BY clause
     if ($count || empty($this->orderBy)) {
         $orderBy = '';
     } else {
         $orderBy = array();
         foreach ($this->orderBy as $criterium) {
             switch ($criterium['order']) {
                 case POT::ORDER_ASC:
                     $orderBy[] = $criterium['field'] . ' ASC';
                     break;
                 case POT::ORDER_DESC:
                     $orderBy[] = $criterium['field'] . ' DESC';
                     break;
             }
         }
         $orderBy = ' ORDER BY ' . implode(', ', $orderBy);
     }
     return 'SELECT ' . implode(', ', $fields) . ' FROM ' . implode(', ', $tables) . $where . $orderBy . $this->db->limit($this->limit, $this->offset);
 }
开发者ID:lucasoares,项目名称:webzohcaserver,代码行数:49,代码来源:OTS_Base_List.php

示例2: getSchemaInfo

 /**
  * Returns OTServ database information.
  * 
  * <p>
  * Especialy currently only schema version is available (via <i>'version'</i> key).
  * </p>
  * 
  * @version 0.1.6
  * @since 0.1.6
  * @return array List of schema settings.
  * @throws PDOException On PDO operation error.
  * @example examples/schema.php schema.php
  */
 public function getSchemaInfo()
 {
     $info = array();
     // generates associative array
     /// FIXME: 0.2.0 - Use PDO::FETCH_KEY_ASSOC
     foreach ($this->db->query('SELECT ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('value') . ' FROM ' . $this->db->tableName('schema_info')) as $row) {
         $info[$row['name']] = $row['version'];
     }
     return $info;
 }
开发者ID:lucasoares,项目名称:webzohcaserver,代码行数:23,代码来源:OTS.php


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