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


PHP Kwf_Model_Select::whereId方法代码示例

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


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

示例1: testChildCountEager

 public function testChildCountEager()
 {
     $s = new Kwf_Model_Select();
     $s->whereId(1);
     $s->expr('parent_child_count');
     $this->_modelChild->getRow($s)->parent_child_count;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:7,代码来源:Test.php

示例2: testSiblingEager

 public function testSiblingEager()
 {
     $s = new Kwf_Model_Select();
     $s->whereId(1);
     $s->expr('sibling_value');
     $row = $this->_modelChild->getRow($s);
     $this->assertEquals(105, $row->sibling_value);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:8,代码来源:Test.php

示例3: testChildCountExpression

 public function testChildCountExpression()
 {
     $s = new Kwf_Model_Select();
     $s->expr('child_count');
     $s->whereId(1);
     $row = $this->_modelFoo->getRow($s);
     $this->assertEquals(2, $row->child_count);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:8,代码来源:Test.php

示例4: testGetRow

 public function testGetRow()
 {
     $model = $this->_m;
     $model->getRow(1)->delete();
     $this->assertEquals(null, $model->getRow(1));
     $s = new Kwf_Model_Select(array('ignoreDeleted' => true));
     $s->whereId(1);
     $this->assertEquals(1, count($model->getRow($s)));
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:9,代码来源:Test.php

示例5: testParentExpr

 public function testParentExpr()
 {
     $s = new Kwf_Model_Select();
     $s->whereId(1);
     $row = $this->_modelChild->getRow($s);
     $this->assertEquals($row->parent_foo, 5);
     $s2 = clone $s;
     $s2->expr('parent_foo');
     $row = $this->_modelChild->getRow($s2);
     $this->assertEquals($row->parent_foo, 5);
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:11,代码来源:Test.php

示例6: testParentExpr

 public function testParentExpr()
 {
     $modelChild = Kwf_Model_Abstract::getInstance('Kwf_Model_FnF_ParentExprDeletedFlag_ChildModel');
     $s = new Kwf_Model_Select();
     $s->whereId(1);
     $row = $modelChild->getRow($s);
     $this->assertEquals($row->parent_foo, 5);
     $s2 = clone $s;
     $s2->expr('parent_foo');
     $row = $modelChild->getRow($s2);
     $this->assertEquals($row->parent_foo, 5);
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:12,代码来源:Test.php

示例7: testCountRows

 public function testCountRows()
 {
     $fnf = new Kwf_Model_FnF();
     $fnf->setData(array(array('id' => 2, 'name' => 'foo'), array('id' => 18, 'name' => 'bar'), array('id' => 456, 'name' => 'bar2')));
     $proxy = new Kwf_Model_Proxy(array('proxyModel' => $fnf));
     $this->assertEquals(3, $proxy->countRows());
     $select = new Kwf_Model_Select();
     $select->whereId(2);
     $fnf = new Kwf_Model_FnF();
     $fnf->setData(array(array('id' => 2, 'name' => 'foo'), array('id' => 18, 'name' => 'bar'), array('id' => 456, 'name' => 'bar2')));
     $proxy = new Kwf_Model_Proxy(array('proxyModel' => $fnf));
     $this->assertEquals(1, $proxy->countRows($select));
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:13,代码来源:ModelTest.php

示例8: 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

示例9: getRow

 /**
  * Should return the specified row, componentId and id has to be defined
  */
 public function getRow($select)
 {
     $componentId = $this->_getComponentId($select);
     $masterId = $this->_getId($select);
     if ($componentId && $masterId) {
         $select = new Kwf_Model_Select();
         $c = Kwf_Component_Data_Root::getInstance()->getComponentById($componentId, array('ignoreVisible' => true));
         $select->whereEquals('component_id', $c->chained->dbId);
         $select->whereEquals('id', $masterId);
         $proxyRow = $this->_proxyModel->getRow($select);
         return $this->getRowByProxiedRow($proxyRow, $componentId);
     } else {
         $trlRow = $this->_trlModel->getRow($select);
         $masterSelect = new Kwf_Model_Select();
         $masterSelect->whereId($trlRow->master_id);
         $masterRow = $this->_proxyModel->getRow($masterSelect);
         return $this->getRowByProxiedRow($masterRow, $trlRow->component_id);
     }
     throw new Kwf_Exception_NotYetImplemented();
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:23,代码来源:Model.php

示例10: onRowEvent

 public function onRowEvent(Kwf_Events_Event_Row_Abstract $ev)
 {
     $eventCls = get_class($ev);
     $unionModel = $this->_getModel();
     $sourceRow = $ev->row;
     $sourceModel = $sourceRow->getModel();
     foreach ($unionModel->getUnionModels() as $modelKey => $m) {
         if ($m === $sourceModel) {
             $s = new Kwf_Model_Select();
             $s->whereId($modelKey . $sourceRow->{$sourceModel->getPrimaryKey()});
             $s->ignoreDeleted();
             $unionRow = $unionModel->getRow($s);
             if (!$unionRow) {
                 $unionRow = $unionModel->_getRowById($modelKey . $sourceRow->{$sourceModel->getPrimaryKey()});
                 $this->fireEvent(new Kwf_Events_Event_Row_Deleted($unionRow));
             } else {
                 $this->fireEvent(new $eventCls($unionRow));
             }
             return;
         }
     }
     throw new Kwf_Exception("Didn't find sourceModel as unionModel");
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:23,代码来源:Events.php

示例11: _convertSelect

 private function _convertSelect($select, $modelKey, $m)
 {
     $s = new Kwf_Model_Select();
     if ($p = $select->getPart(Kwf_Model_Select::WHERE_ID)) {
         if (substr($p, 0, strlen($modelKey)) == $modelKey) {
             $s->whereId(substr($p, strlen($modelKey)));
         } else {
             return null;
         }
     }
     if ($p = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
         foreach ($p as $f => $v) {
             if ($f == 'id') {
                 if (is_array($v)) {
                     $filterV = array();
                     foreach ($v as $i) {
                         if (substr($i, 0, strlen($modelKey)) == $modelKey) {
                             $filterV[] = substr($i, strlen($modelKey));
                         }
                     }
                     if (!$filterV) {
                         return null;
                     }
                     $v = $filterV;
                 } else {
                     if (substr($v, 0, strlen($modelKey)) == $modelKey) {
                         $v = substr($v, strlen($modelKey));
                     } else {
                         return null;
                     }
                 }
             }
             if (in_array($f, $this->_getOwnColumns())) {
                 $f = $this->_mapColumn($m, $f);
                 $s->whereEquals($f, $v);
             }
         }
     }
     if ($p = $select->getPart(Kwf_Model_Select::WHERE_NOT_EQUALS)) {
         foreach ($p as $f => $v) {
             if ($f == 'id') {
                 if (substr($v, 0, strlen($modelKey)) != $modelKey) {
                     continue;
                 } else {
                     $v = substr($v, strlen($modelKey));
                 }
             }
             if (in_array($f, $this->_getOwnColumns())) {
                 $f = $this->_mapColumn($m, $f);
                 $s->whereNotEquals($f, $v);
             }
         }
     }
     if ($p = $select->getPart(Kwf_Model_Select::WHERE_NULL)) {
         foreach ($p as $f) {
             if (in_array($f, $this->_getOwnColumns())) {
                 $f = $this->_mapColumn($m, $f);
                 $s->whereNull($f);
             }
         }
     }
     if ($p = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) {
         foreach ($p as $expr) {
             $e = $this->_convertExpr($expr, $modelKey, $m);
             if ($e) {
                 $s->where($e);
             }
         }
     }
     if ($p = $select->getPart(Kwf_Model_Select::IGNORE_DELETED)) {
         $s->ignoreDeleted($p);
     }
     if (isset($this->_mergeSelects[$modelKey])) {
         $s->merge($this->_mergeSelects[$modelKey]);
     }
     return $s;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:77,代码来源:Union.php

示例12: getExprValue

 public function getExprValue($row, $name)
 {
     if ($name instanceof Kwf_Model_Select_Expr_Interface) {
         $expr = $name;
     } else {
         $expr = $this->_exprs[$name];
     }
     if ($expr instanceof Kwf_Model_Select_Expr_Child_Contains) {
         if (!$row instanceof Kwf_Model_Row_Interface) {
             $row = $this->getRow($row[$this->getPrimaryKey()]);
         }
         $ret = (bool) $row->countChildRows($expr->getChild(), $expr->getSelect());
         return $ret;
     } else {
         if ($expr instanceof Kwf_Model_Select_Expr_Child_First) {
             if (!$row instanceof Kwf_Model_Row_Interface) {
                 $row = $this->getRow($row[$this->getPrimaryKey()]);
             }
             $s = clone $expr->getSelect();
             $s->limit(1);
             $childRows = $row->getChildRows($expr->getChild(), $s);
             if (count($childRows)) {
                 return $childRows[0]->{$expr->getField()};
             } else {
                 return null;
             }
         } else {
             if ($expr instanceof Kwf_Model_Select_Expr_Child) {
                 if (!$row instanceof Kwf_Model_Row_Interface) {
                     $row = $this->getRow($row[$this->getPrimaryKey()]);
                 }
                 $childs = $row->getChildRows($expr->getChild(), $expr->getSelect());
                 return self::_evaluateExprForRowset($childs, $expr->getExpr());
             } else {
                 if ($expr instanceof Kwf_Model_Select_Expr_Parent) {
                     if (!$row instanceof Kwf_Model_Row_Interface) {
                         $row = $this->getRow($row[$this->getPrimaryKey()]);
                     }
                     $reference = $row->getModel()->getReference($expr->getParent());
                     $parentModel = $row->getModel()->getReferencedModel($expr->getParent());
                     $select = new Kwf_Model_Select();
                     $select->whereId($row->{$reference['column']});
                     $select->ignoreDeleted(true);
                     $parent = $parentModel->getRow($select);
                     if (!$parent) {
                         return null;
                     }
                     $field = $expr->getField();
                     if (is_string($field)) {
                         return $parent->{$field};
                     } else {
                         return $this->getExprValue($parent, $field);
                     }
                 } else {
                     if ($expr instanceof Kwf_Model_Select_Expr_Concat) {
                         $ret = '';
                         foreach ($expr->getExpressions() as $e) {
                             if ($e instanceof Kwf_Model_Select_Expr_Interface) {
                                 $ret .= $this->getExprValue($row, $e);
                             } else {
                                 if (is_array($row)) {
                                     $ret .= $row[$e];
                                 } else {
                                     $ret .= $row->{$e};
                                 }
                             }
                         }
                         return $ret;
                     } else {
                         if ($expr instanceof Kwf_Model_Select_Expr_String) {
                             return $expr->getString();
                         } else {
                             if ($expr instanceof Kwf_Model_Select_Expr_Boolean) {
                                 return $expr->getValue();
                             } else {
                                 if ($expr instanceof Kwf_Model_Select_Expr_Integer) {
                                     return $expr->getValue();
                                 } else {
                                     if ($expr instanceof Kwf_Model_Select_Expr_StrPad) {
                                         $f = $expr->getField();
                                         if (is_array($row)) {
                                             $v = $row[$f];
                                         } else {
                                             $v = $row->{$f};
                                         }
                                         // faking mysql's implementation of LPAD / RPAD
                                         // mysql cuts always right when the string is too long, it does not
                                         // depend on the pad-type
                                         if ($expr->getPadLength() < mb_strlen($v)) {
                                             return substr($v, 0, $expr->getPadLength());
                                         }
                                         $padType = STR_PAD_RIGHT;
                                         if ($expr->getPadType() == Kwf_Model_Select_Expr_StrPad::LEFT) {
                                             $padType = STR_PAD_LEFT;
                                         } else {
                                             if ($expr->getPadType() == Kwf_Model_Select_Expr_StrPad::RIGHT) {
                                                 $padType = STR_PAD_RIGHT;
                                             }
                                         }
                                         return str_pad($v, $expr->getPadLength(), $expr->getPadStr(), $padType);
//.........这里部分代码省略.........
开发者ID:koala-framework,项目名称:koala-framework,代码行数:101,代码来源:Abstract.php

示例13: testCountSelectWhereId

 public function testCountSelectWhereId()
 {
     $s = new Kwf_Model_Select();
     $s->whereId('1m1');
     $this->assertEquals(1, $this->_m->countRows($s));
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:6,代码来源:Test.php


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