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


PHP Query::getWhere方法代码示例

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


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

示例1: updateCount

 /**
  * Updates the total count of models. For better performance
  * the count is only updated on edges, which is when new models
  * need to be loaded.
  */
 private function updateCount()
 {
     // The count only needs to be updated when the pointer is
     // on the edges
     if ($this->pointer % $this->limit != 0 && $this->pointer < $this->count) {
         return;
     }
     $model = $this->query->getModel();
     $newCount = $model::totalRecords($this->query->getWhere());
     // It's possible when iterating over models that something
     // is modified or deleted that causes the model count
     // to decrease. If the count has decreased then we
     // shift the pointer to prevent overflow.
     // This calculation is based on the assumption that
     // the first N (count - count') models are deleted.
     if ($this->count != 0 && $newCount < $this->count) {
         $this->pointer = (int) max(0, $this->pointer - ($this->count - $newCount));
     }
     // If the count has increased then the pointer is still
     // valid. Update the count to include the extra models.
     $this->count = $newCount;
 }
开发者ID:jaredtking,项目名称:pulsar,代码行数:27,代码来源:Iterator.php

示例2: buildWhereClause

 /**
  * Build SQL WHERE clause
  * @param Query $query
  * @param &array $params
  * @return string
  */
 protected function buildWhereClause(Query $query, &$params)
 {
     $where = '';
     foreach ($query->getWhere() as $condition) {
         $where .= "\n\tAND (" . $condition[0] . ')';
         if (!empty($condition[1])) {
             $params = array_merge($params, $condition[1]);
         }
     }
     if ($where) {
         return "\nWHERE\n\t" . substr($where, 6);
         // replace first AND with WHERE
     } else {
         return '';
     }
 }
开发者ID:jamend,项目名称:selective-orm,代码行数:22,代码来源:Driver.php

示例3: evaluateQuery

 public function evaluateQuery(Query $query)
 {
     $select = $this->evaluateSelect($query->getSelect()) . " ";
     $from = $this->evaluateFrom($query->getFrom()) . " ";
     $where = $this->evaluateWhere($query->getWhere()) . " ";
     $order = $this->evaluateOrder($query->getOrder()) . " ";
     $groupBy = $this->evaluateGroupBy($query->getGroupBy()) . " ";
     $limit = '';
     if ($query->hasLimit()) {
         $limit = 'LIMIT ' . $query->getLimitMax() . ' ' . $query->getLimitOffset() . ' ';
         // http://www.postgresql.org/docs/8.1/static/queries-limit.html
     }
     return $select . $from . $where . $order . $limit . $groupBy;
 }
开发者ID:fkali,项目名称:yupp,代码行数:14,代码来源:core.db.DatabasePostgreSQL.class.php

示例4: evaluateQuery

 public function evaluateQuery(Query $query)
 {
     $select = $this->evaluateSelect($query->getSelect()) . ' ';
     $from = $this->evaluateFrom($query->getFrom()) . ' ';
     $where = $this->evaluateWhere($query->getWhere()) . ' ';
     $order = $this->evaluateOrder($query->getOrder()) . ' ';
     $groupBy = $this->evaluateGroupBy($query->getGroupBy()) . ' ';
     $limit = '';
     if ($query->hasLimit()) {
         $limit = 'LIMIT ' . $query->getLimitOffset() . ', ' . $query->getLimitMax() . ' ';
         // http://www.sqlite.org/lang_select.html
     }
     return $select . $from . $where . $order . $limit . $groupBy;
 }
开发者ID:fkali,项目名称:yupp,代码行数:14,代码来源:core.db.DatabaseSQLite.class.php

示例5: addBetween

            $params = "'" . implode("','", $params) . "'";
        }
        $this->where($column . ' NOT IN (' . $params . ')');
    }
    public function addBetween($column, $start, $stop)
    {
        $this->where($column . ' BETWEEN ' . $start . ' AND ' . $stop);
    }
    public function addNotBetween($column, $start, $stop)
    {
        $this->addWhere($column . ' BETWEEN ' . $start . ' AND ' . $stop);
    }
    /**
     * Add join
     *
     * @access public
     * @param string $table table name
     * @param string $condition condition to search
     * @param string $type type join
     * @return void
     */
    public function addJoin($table, $condition, $type = 'LEFT')
    {
        $this->join .= ' ' . $type . ' JOIN ' . $table . ' ON ' . $condition;
    }
}
$query = new Query();
$query->where('id=40');
$query->where('put<30');
echo $query->getWhere();
开发者ID:rotiga,项目名称:hakerlib,代码行数:30,代码来源:query.class.php

示例6: evaluateQuery

 public function evaluateQuery(Query $query)
 {
     $select = $this->evaluateSelect($query->getSelect()) . ' ';
     $from = '';
     $order = $this->evaluateOrder($query->getOrder()) . ' ';
     $groupBy = $this->evaluateGroupBy($query->getGroupBy()) . ' ';
     // SQLServer 2008 no tiene LIMIT, hay que hacerlo con una subquery usando ROWNUM
     // Soluciona problema de paginacion en SQLServer, como esta en DAL::listAll()
     //
     if ($query->hasLimit()) {
         // FIXME:
         // El filtro del where que no es el filtro por rowNum
         // debe hacerse en la consulta interna, sino se toman
         // rowNums en la consulta interna que luego no estan
         // en la consulta final, eso afecta al resultado paginado,
         // porque se pagina por rowNum de rows que no matchean el where, ej:
         //  - consulta interna devuelve 1,2,3,4,5,6,7,8
         //  - consulta externa tiene max=3, offset=0
         //  - where matchea solo 2,4,5,7
         //  - el resultado es solo 2, en lugar de 2,4,5 (son los primeros 3 que matchean)
         //
         // problema, el where incluye condiciones que no son sobre la tabla utilizada
         // en la consulta interna, esto afecta?
         $tableName = $query->getLimitTable();
         $offset = $query->getLimitOffset();
         $max = $query->getLimitMax();
         // La consulta interna es para hacer paginacion
         // WHERE: Las condiciones donde dice tableName pone T2 (no puede evaluar condiciones sobre atributos de tablas no mencionados en el FROM)
         //  - http://social.msdn.microsoft.com/Forums/sqlserver/en-US/3b2e0875-e98c-4931-bcb4-e9f449b637d7/the-multipart-identifier-aliasfield-could-not-be-bound
         // Hago el evaluate del from aca porque tengo que cambiar el FROM de tableName por la subconsulta necesaria para el limit
         $queryFrom = $query->getFrom();
         $alias;
         if (count($queryFrom) == 0) {
             // ERROR! es obligatorio por lo menos una!
             throw new Exception("FROM no puede ser vacio");
         } else {
             /*
             $res = "FROM ";
             foreach ($queryFrom as $table)
             {
                if ( $table->name == $tableName )
                {
                   $alias = $table->alias;
                   
                   $res .= '( SELECT ROW_NUMBER() OVER (ORDER BY id) AS rowNum, * '.
                           'FROM '. $tableName .
                           $this->evaluateWhere( $query->getWhere() ) .
                           ' ) '. $alias .', ';
                }
                else
                {
                   $res .= $table->name .' '. $table->alias .', ';
                }
             }
             $from = substr($res, 0, -2) .' ';
             */
             $alias = 'subq';
             // * selecciona multiples columnas con mismo nombre en distintas tablas
             $subquery = '( ' . $select . ', ROW_NUMBER() OVER (ORDER BY ' . $tableName . '.id) AS rowNum ' . $this->evaluateFrom($query->getFrom()) . ' ' . $this->evaluateWhere($query->getWhere()) . ' ' . $order . $groupBy . ' ) ' . $alias . ' ';
             $from = 'FROM ' . $subquery;
             $select = 'SELECT * ';
             // Select para la query ppal. agregaciones y group se harian en la subquery
         }
         $where = 'WHERE ' . $alias . '.rowNum-1 >= ' . $offset . ' AND ' . $alias . '.rowNum-1 < ' . ($offset + $max);
         return $select . $from . $where;
     }
     // hasLimit
     // !hasLimit
     $from = $this->evaluateFrom($query->getFrom()) . ' ';
     $where = $this->evaluateWhere($query->getWhere()) . ' ';
     return $select . $from . $where . $order . $groupBy;
 }
开发者ID:fkali,项目名称:yupp,代码行数:72,代码来源:core.db.DatabaseSQLServer.class.php


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