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


PHP xPDOQuery::prepare方法代码示例

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


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

示例1: getResults

 protected function getResults(xPDOQuery &$c)
 {
     $list = array();
     $this->currentIndex = 0;
     if ($c->prepare()) {
         if ($c->stmt->execute()) {
             while ($row = $c->stmt->fetch(PDO::FETCH_ASSOC)) {
                 $object_id = $row['object_id'];
                 if (empty($list[$object_id])) {
                     $list[$object_id] = $row;
                     $list[$object_id]['tvs'] = array();
                     $this->currentIndex++;
                 }
                 if (!empty($row['tv_name'])) {
                     $list[$object_id]['tvs'][$row['tv_name']] = array('tv_id' => $row['tv_id'], 'caption' => $row['tv_caption'], 'category' => $row['tv_category'], 'value_id' => $row['tv_value_id'], 'value' => $row['tv_value']);
                 }
             }
         } else {
             if ($c->stmt->errorCode() !== "00000") {
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, __CLASS__);
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($c->stmt->errorInfo(), true));
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, $c->toSQL());
             }
         }
     }
     return $list;
 }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:27,代码来源:getdata.class.php

示例2: prepareQueryBeforeCount

 /**
  * @param xPDOQuery $c
  *
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modMediaSource', 'Source');
     $c->leftJoin($this->classKey, 'Thumb', "`{$this->classKey}`.`id` = `Thumb`.`parent`");
     $c->groupby($this->classKey . '.id');
     $c->select('`Source`.`name` as `source_name`');
     $c->select('`Thumb`.`url` as `thumbnail`');
     $c->where(array('resource_id' => $this->getProperty('resource_id')));
     $parent = $this->getProperty('parent');
     if ($parent !== false) {
         $c->where(array('parent' => $parent));
     }
     $query = trim($this->getProperty('query'));
     if (!empty($query)) {
         $c->where(array('file:LIKE' => "%{$query}%", 'OR:name:LIKE' => "%{$query}%", 'OR:alt:LIKE' => "%{$query}%", 'OR:description:LIKE' => "%{$query}%", 'OR:add:LIKE' => "%{$query}%"));
     }
     $tags = array_map('trim', explode(',', $this->getProperty('tags')));
     if (!empty($tags[0])) {
         $tags = implode("','", $tags);
         $c->innerJoin('msResourceFileTag', 'Tag', "`{$this->classKey}`.`id` = `Tag`.`file_id` AND `Tag`.`tag` IN ('" . $tags . "')");
         $c->groupby($this->classKey . '.id');
         $c->prepare();
         $this->modx->log(1, $c->toSQL());
     }
     return $c;
 }
开发者ID:svyatoslavteterin,项目名称:belton.by,代码行数:31,代码来源:getlist.class.php

示例3: prepareQuery

 /**
  * Set parameters and prepare query
  *
  * @return PDOStatement
  */
 public function prepareQuery()
 {
     if (!empty($this->config['limit'])) {
         $time = microtime(true);
         $this->query->limit($this->config['limit'], $this->config['offset']);
         $this->addTime('Limited to <b>' . $this->config['limit'] . '</b>, offset <b>' . $this->config['offset'] . '</b>', microtime(true) - $time);
     }
     return $this->query->prepare();
 }
开发者ID:WhisperingTree,项目名称:blog,代码行数:14,代码来源:pdofetch.class.php

示例4: prepareQuery

 /**
  * Set parameters and prepare query
  *
  * @return PDOStatement
  */
 public function prepareQuery()
 {
     if ($limit = (int) $this->config['limit']) {
         $offset = (int) $this->config['offset'];
         $time = microtime(true);
         $this->query->limit($limit, $offset);
         $this->addTime('Limited to <b>' . $limit . '</b>, offset <b>' . $offset . '</b>', microtime(true) - $time);
     }
     return $this->query->prepare();
 }
开发者ID:Jako,项目名称:pdoTools,代码行数:15,代码来源:pdofetch.class.php

示例5: countTotal

 protected function countTotal($className, xPDOQuery &$query)
 {
     if (!$query->prepare()) {
         return false;
     }
     $sql = "SELECT count(*) as count FROM (" . $query->toSQL() . ") as t;";
     if (!($stmt = $this->modx->prepare($sql)) or !$stmt->execute()) {
         return false;
     }
     return current((array) $stmt->fetch(PDO::FETCH_NUM));
 }
开发者ID:bendasvadim,项目名称:NewsModxBox,代码行数:11,代码来源:getlist.class.php

示例6: getResults

 protected function getResults(xPDOQuery &$c)
 {
     $list = array();
     $this->currentIndex = 0;
     if ($c->prepare() && $c->stmt->execute()) {
         while ($row = $c->stmt->fetch(PDO::FETCH_ASSOC)) {
             $object_id = $row['object_id'];
             if (empty($list[$object_id])) {
                 $list[$object_id] = $row;
                 $this->currentIndex++;
             }
         }
     }
     return $list;
 }
开发者ID:bendasvadim,项目名称:NewsModxBox,代码行数:15,代码来源:getdata.class.php

示例7: rewindOriginal

 /**
  *
  */
 public function rewindOriginal()
 {
     $this->index = 0;
     if (!empty($this->stmt)) {
         $this->stmt->closeCursor();
     }
     $this->stmt = $this->criteria->prepare();
     $tstart = microtime(true);
     if ($this->stmt && $this->stmt->execute()) {
         $this->xpdo->queryTime += microtime(true) - $tstart;
         $this->xpdo->executedQueries++;
         $this->fetch();
     } elseif ($this->stmt) {
         $this->xpdo->queryTime += microtime(true) - $tstart;
         $this->xpdo->executedQueries++;
     }
 }
开发者ID:jgulledge19,项目名称:MenuBuilder,代码行数:20,代码来源:MbIterator.php

示例8: prepareQueryBeforeCount

 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $form = $this->getProperty('form');
     if (!empty($form)) {
         $c->andCondition(array('form' => $form));
     }
     $context_key = $this->getProperty('context_key');
     if (!empty($context_key)) {
         $c->andCondition(array('context_key' => $context_key));
     }
     $startDate = $this->getProperty('startDate');
     if ($startDate != '') {
         $c->andCondition(array('date:>' => strtotime($startDate . ' 00:00:00')));
     }
     $endDate = $this->getProperty('endDate');
     if ($endDate != '') {
         $c->andCondition(array('date:<' => strtotime($endDate . ' 23:59:59')));
     }
     $c->prepare();
     return $c;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:21,代码来源:export.class.php

示例9: niceQuery

 /**
  * Returns select statement for easy reading
  *
  * @access public
  * @param xPDOQuery $query The query to print
  * @return string The select statement
  * @author Coroico <coroico@wangba.fr>
  */
 public function niceQuery(xPDOQuery $query = null)
 {
     $searched = array("SELECT", "GROUP_CONCAT", "LEFT JOIN", "INNER JOIN", "EXISTS", "LIMIT", "FROM", "WHERE", "GROUP BY", "HAVING", "ORDER BY", "OR", "AND", "IFNULL", "ON", "MATCH", "AGAINST", "COUNT");
     $replace = array(" \r\nSELECT", " \r\nGROUP_CONCAT", " \r\nLEFT JOIN", " \r\nINNER JOIN", " \r\nEXISTS", " \r\nLIMIT", " \r\nFROM", " \r\nWHERE", " \r\nGROUP BY", " \r\nHAVING", " ORDER BY", " \r\nOR", " \r\nAND", " \r\nIFNULL", " \r\nON", " \r\nMATCH", " \r\nAGAINST", " \r\nCOUNT");
     $output = '';
     if (isset($query)) {
         $query->prepare();
         $output = str_replace($searched, $replace, " " . $query->toSQL());
     }
     return $output;
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:19,代码来源:lingua.class.php

示例10: prepareQueryAfterCount

 public function prepareQueryAfterCount(xPDOQuery $c)
 {
     $c->prepare();
     $this->modx->log(modX::LOG_LEVEL_ERROR, $c->toSql());
     return $c;
 }
开发者ID:sergant210,项目名称:AdminTools,代码行数:6,代码来源:getlist.class.php

示例11: niceQuery

 /**
  * Returns select statement for easy reading.
  *
  * @param xPDOQuery $query The query to print
  *
  * @return string The select statement
  *
  * @author Coroico <coroico@wangba.fr>
  */
 public function niceQuery(xPDOQuery $query = null)
 {
     $searched = array('SELECT', 'GROUP_CONCAT', 'LEFT JOIN', 'INNER JOIN', 'EXISTS', 'LIMIT', 'FROM', 'WHERE', 'GROUP BY', 'HAVING', 'ORDER BY', 'OR', 'AND', 'IFNULL', 'ON', 'MATCH', 'AGAINST', 'COUNT');
     $replace = array(" \r\nSELECT", " \r\nGROUP_CONCAT", " \r\nLEFT JOIN", " \r\nINNER JOIN", " \r\nEXISTS", " \r\nLIMIT", " \r\nFROM", " \r\nWHERE", " \r\nGROUP BY", " \r\nHAVING", ' ORDER BY', " \r\nOR", " \r\nAND", " \r\nIFNULL", " \r\nON", " \r\nMATCH", " \r\nAGAINST", " \r\nCOUNT");
     $output = '';
     if (isset($query)) {
         $query->prepare();
         $output = str_replace($searched, $replace, ' ' . $query->toSQL());
     }
     return $output;
 }
开发者ID:virtudraft,项目名称:bbbx,代码行数:20,代码来源:bbbx.class.php


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