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


PHP Kwf_Model_Select::getPart方法代码示例

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


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

示例1: getRow

 public function getRow($select)
 {
     if (!is_object($select)) {
         $select = new Kwf_Model_Select($select);
     }
     $id = null;
     if ($select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
         foreach ($select->getPart(Kwf_Model_Select::WHERE_EQUALS) as $k => $i) {
             if ($k == 'id') {
                 $id = $i;
             }
         }
     }
     $componentId = $this->_getComponentId($select);
     if ($id && !$componentId) {
         //only id passed, in detail form controller
         $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, array('ignoreVisible' => true));
         $select->whereEquals('component_id', $c->parent->chained->dbId);
         $select->whereEquals('id', $c->id);
         $componentId = $c->parent->dbId;
     } else {
         if ($componentId && $id) {
             $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
             $select->whereEquals('component_id', $c->chained->dbId);
             $select->whereEquals('id', $id);
         } else {
             throw new Kwf_Exception("invalid select");
         }
     }
     $proxyRow = $this->_proxyModel->getRow($select);
     return $this->getRowByProxiedRow($proxyRow, $componentId);
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:32,代码来源:AdminModel.php

示例2: testSelect

 public function testSelect()
 {
     $select = new Kwf_Model_Select();
     $select->where('foo = ?', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE), array(array('foo = ?', 1, null)));
     $select->where('bar = ?', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE), array(array('foo = ?', 1, null), array('bar = ?', 1, null)));
     $select->whereEquals('foo', 1);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 1));
     $select->whereEquals('foo', 'bar');
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 'bar'));
     $select->whereEquals('foo2', 'bar2');
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_EQUALS), array('foo' => 'bar', 'foo2' => 'bar2'));
     $select->order('foo');
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => 'foo', 'direction' => 'ASC')));
     $select->order('foo2', 'DESC');
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => 'foo', 'direction' => 'ASC'), array('field' => 'foo2', 'direction' => 'DESC')));
     $select->limit(10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_OFFSET), null);
     $select->limit(20);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 20);
     $select->limit(25, 10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_COUNT), 25);
     $this->assertEquals($select->getPart(Kwf_Model_Select::LIMIT_OFFSET), 10);
     $this->assertEquals(count($select->getParts()), 5);
     $select = new Kwf_Model_Select(array('id' => 1));
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 1);
     $select->whereId(10);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 10);
     $select->whereId(11);
     $this->assertEquals($select->getPart(Kwf_Model_Select::WHERE_ID), 11);
     $select = new Kwf_Model_Select();
     $select->order(Kwf_Model_Select::ORDER_RAND);
     $this->assertEquals($select->getPart(Kwf_Model_Select::ORDER), array(array('field' => Kwf_Model_Select::ORDER_RAND, 'direction' => 'ASC')));
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:36,代码来源:SelectTest.php

示例3: _getQuery

 private function _getQuery(Kwf_Model_Select $select)
 {
     $where = array();
     if ($equals = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
         foreach ($equals as $k => $v) {
             $where[$k] = $v;
         }
     }
     if ($exprs = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) {
         foreach ($exprs as $e) {
             if ($e instanceof Kwf_Model_Select_Expr_Equals) {
                 $where[$e->getField()] = $e->getValue();
             } else {
                 if ($e instanceof Kwf_Model_Select_Expr_NotEquals) {
                     $where[$e->getField()]['$ne'] = $e->getValue();
                 } else {
                     if ($e instanceof Kwf_Model_Select_Expr_HigherDate) {
                         $where[$e->getField()]['$gt'] = new MongoDate(strtotime($e->getValue()));
                     } else {
                         if ($e instanceof Kwf_Model_Select_Expr_SmallerDate) {
                             $where[$e->getField()]['$lt'] = new MongoDate(strtotime($e->getValue()));
                         } else {
                             if ($e instanceof Kwf_Model_Select_Expr_HigherEqualDate) {
                                 $where[$e->getField()]['$gte'] = new MongoDate(strtotime($e->getValue()));
                             } else {
                                 if ($e instanceof Kwf_Model_Select_Expr_SmallerEqualDate) {
                                     $where[$e->getField()]['$lte'] = new MongoDate(strtotime($e->getValue()));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($id = $select->getPart(Kwf_Model_Select::WHERE_ID)) {
         $where['id'] = $id;
         //TODO dynam.
     }
     return $where;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:41,代码来源:Mongo.php

示例4: _selectData

 protected function _selectData(Kwf_Model_Select $select, array $row)
 {
     if ($where = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
         foreach ($where as $f => $v) {
             if (!is_array($v)) {
                 $v = array($v);
             }
             $rv = $this->_rowValue($f, $row);
             if (is_null($rv)) {
                 return false;
             }
             if (!in_array($rv, $v)) {
                 return false;
             }
         }
     }
     if ($where = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) {
         foreach ($where as $expr) {
             if (!$this->_checkExpressions($expr, $row)) {
                 return false;
             }
         }
     }
     if ($where = $select->getPart(Kwf_Model_Select::WHERE_NOT_EQUALS)) {
         $foundOneMatching = false;
         foreach ($where as $f => $v) {
             if (!is_array($v)) {
                 $v = array($v);
             }
             $rv = $this->_rowValue($f, $row);
             if ($rv && in_array($rv, $v)) {
                 $foundOneMatching = true;
                 break;
             }
         }
         if ($foundOneMatching) {
             return false;
         }
     }
     if ($where = $select->getPart(Kwf_Model_Select::WHERE_NULL)) {
         foreach ($where as $f) {
             $rv = $this->_rowValue($f, $row);
             if (!is_null($rv)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:49,代码来源:CSV.php

示例5: _applySelect

 protected function _applySelect(Zend_Db_Select $dbSelect, Kwf_Model_Select $select)
 {
     if ($dbSelect instanceof Zend_Db_Table_Select) {
         $dbSelect->setIntegrityCheck(false);
     }
     if ($whereEquals = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
         foreach ($whereEquals as $field => $value) {
             if (is_array($value)) {
                 if ($value) {
                     foreach ($value as &$v) {
                         if (!is_int($v)) {
                             $v = $this->_fixStupidQuoteBug($v);
                             $v = $this->getAdapter()->quote($v);
                         }
                     }
                     $value = implode(', ', $value);
                     $dbSelect->where($this->_formatField($field, $dbSelect) . " IN ({$value})");
                 } else {
                     $dbSelect->where('0');
                 }
             } else {
                 $value = $this->_fixStupidQuoteBug($value);
                 $dbSelect->where($this->_formatField($field, $dbSelect) . " = ?", $value);
             }
         }
     }
     if ($whereNotEquals = $select->getPart(Kwf_Model_Select::WHERE_NOT_EQUALS)) {
         foreach ($whereNotEquals as $field => $value) {
             if (is_array($value)) {
                 foreach ($value as &$v) {
                     if (!is_int($v)) {
                         $v = $this->_fixStupidQuoteBug($v);
                         $v = $this->getAdapter()->quote($v);
                     }
                 }
                 $value = implode(', ', $value);
                 $dbSelect->where($this->_formatField($field, $dbSelect) . " NOT IN ({$value})");
             } else {
                 $value = $this->_fixStupidQuoteBug($value);
                 $dbSelect->where($this->_formatField($field, $dbSelect) . " != ?", $value);
             }
         }
     }
     if ($this->_hasDeletedFlag && !$select->getPart(Kwf_Model_Select::IGNORE_DELETED)) {
         $dbSelect->where("deleted = 0");
     }
     if ($where = $select->getPart(Kwf_Model_Select::WHERE)) {
         foreach ($where as $w) {
             $dbSelect->where($w[0], $w[1], $w[2]);
         }
     }
     if ($whereId = $select->getPart(Kwf_Model_Select::WHERE_ID)) {
         $whereId = $this->_fixStupidQuoteBug($whereId);
         $dbSelect->where($this->_formatField($this->getPrimaryKey(), $dbSelect) . " = ?", $whereId);
     }
     if ($whereNull = $select->getPart(Kwf_Model_Select::WHERE_NULL)) {
         foreach ($whereNull as $field) {
             $dbSelect->where("ISNULL(" . $this->_formatField($field, $dbSelect) . ")");
         }
     }
     if ($other = $select->getPart(Kwf_Model_Select::OTHER)) {
         foreach ($other as $i) {
             call_user_func_array(array($dbSelect, $i['method']), $i['arguments']);
         }
     }
     if ($whereExpression = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) {
         foreach ($whereExpression as $expr) {
             $expr->validate();
             $dbSelect->where($this->_createDbSelectExpression($expr, $dbSelect));
         }
     }
     if ($exprs = $select->getPart(Kwf_Model_Select::EXPR)) {
         foreach ($exprs as $field) {
             if (!($col = $this->_formatField($field, $dbSelect))) {
                 throw new Kwf_Exception("Expression '{$field}' not found");
             }
             $dbSelect->from(null, array($field => new Zend_Db_Expr($col)));
         }
     }
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:80,代码来源:Db.php


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