本文整理汇总了PHP中Kwf_Model_Select::union方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Select::union方法的具体用法?PHP Kwf_Model_Select::union怎么用?PHP Kwf_Model_Select::union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Model_Select
的用法示例。
在下文中一共展示了Kwf_Model_Select::union方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRowUpdatesFinished
public function onRowUpdatesFinished(Kwf_Events_Event_Row_UpdatesFinished $event)
{
if ($this->_updates) {
$or = array();
foreach ($this->_updates as $key => $values) {
if ($key === 'component_id') {
$or[] = new Kwf_Model_Select_Expr_And(array(new Kwf_Model_Select_Expr_Equal('component_id', array_unique($values)), new Kwf_Model_Select_Expr_Equal('type', 'component')));
} else {
if ($key === 'master-component_id') {
$or[] = new Kwf_Model_Select_Expr_And(array(new Kwf_Model_Select_Expr_Equal('component_id', array_unique($values)), new Kwf_Model_Select_Expr_Equal('type', 'master')));
} else {
$and = array();
foreach ($values as $k => $v) {
if (substr($v, -1) == '%') {
$v = substr($v, 0, -1);
$and[] = new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equal($k, $v), new Kwf_Model_Select_Expr_Like($k, $v . '-%'), new Kwf_Model_Select_Expr_Like($k, $v . '_%')));
} else {
if (strpos($v, '%') !== false) {
$and[] = new Kwf_Model_Select_Expr_Like($k, $v);
} else {
$and[] = new Kwf_Model_Select_Expr_Equal($k, $v);
}
}
}
$or[] = new Kwf_Model_Select_Expr_And($and);
}
}
}
$select = new Kwf_Model_Select();
$select->where($or[0]);
unset($or[0]);
foreach ($or as $i) {
$s = new Kwf_Model_Select();
$s->where($i);
$select->union($s);
}
Kwf_Component_Cache::getInstance()->deleteViewCache($select);
$this->_updates = array();
}
foreach ($this->_pageParentChanges as $changes) {
$oldParentId = $changes['oldParentId'];
$newParentId = $changes['newParentId'];
$componentId = $changes['componentId'];
$length = strlen($oldParentId);
$like = $oldParentId . '_' . $componentId;
$model = Kwf_Component_Cache::getInstance()->getModel();
while ($model instanceof Kwf_Model_Proxy) {
$model = $model->getProxyModel();
}
if ($model instanceof Kwf_Model_Db) {
$db = Kwf_Registry::get('db');
$newParentId = $db->quote($newParentId);
$where[] = 'expanded_component_id = ' . $db->quote($like);
$where[] = 'expanded_component_id LIKE ' . str_replace('_', '\\_', $db->quote($like . '-%'));
$where[] = 'expanded_component_id LIKE ' . str_replace('_', '\\_', $db->quote($like . '_%'));
$sql = "UPDATE cache_component\n SET expanded_component_id=CONCAT(\n {$newParentId}, SUBSTRING(expanded_component_id, {$length})\n )\n WHERE " . implode(' OR ', $where);
$model->executeSql($sql);
$this->_log("expanded_component_id={$like}%->{$newParentId}");
} else {
$model = Kwf_Component_Cache::getInstance()->getModel();
$select = $model->select()->where(new Kwf_Model_Select_Expr_Like('expanded_component_id', $like . '%'));
foreach ($model->getRows($select) as $row) {
$oldExpandedId = $row->expanded_component_id;
$newExpandedId = $newParentId . substr($oldExpandedId, $length);
$row->expanded_component_id = $newExpandedId;
$row->save();
$this->_log("expanded_component_id={$oldExpandedId}->{$newExpandedId}");
}
}
}
$this->_pageParentChanges = array();
}
示例2: testUnion
public function testUnion()
{
$model = new Kwf_Model_DbWithConnection_ImportExport_Model(array("table" => $this->_tableName));
$s1 = new Kwf_Model_Select();
$s1->whereEquals('id', 1);
$s2 = new Kwf_Model_Select();
$s2->whereEquals('id', 2);
$s1->union($s2);
$this->assertEquals(count($model->export(Kwf_Model_Interface::FORMAT_ARRAY, $s1)), 2);
$this->assertEquals(count($model->getRows($s1)), 2);
}
示例3: testUnion
public function testUnion()
{
$model = new Kwf_Model_FnF();
$model->setData(array(array('id' => 1, 'value' => 'foo'), array('id' => 2, 'value' => 'bar')));
$s1 = new Kwf_Model_Select();
$s1->whereEquals('id', 1);
$s2 = new Kwf_Model_Select();
$s2->whereEquals('id', 2);
$s1->union($s2);
$this->assertEquals($model->countRows($s1), 2);
$this->assertEquals(count($model->getRows($s1)), 2);
$this->assertEquals(count($model->export(Kwf_Model_Interface::FORMAT_ARRAY, $s1)), 2);
}
示例4: _buildSelectForDelete
protected function _buildSelectForDelete($updates)
{
$or = array();
foreach ($updates as $key => $values) {
if ($key === 'component_id') {
$or[] = new Kwf_Model_Select_Expr_And(array(new Kwf_Model_Select_Expr_Equal('component_id', array_unique($values)), new Kwf_Model_Select_Expr_Equal('type', 'component')));
} else {
if ($key === 'master-component_id') {
$or[] = new Kwf_Model_Select_Expr_And(array(new Kwf_Model_Select_Expr_Equal('component_id', array_unique($values)), new Kwf_Model_Select_Expr_Equal('type', 'master')));
} else {
$and = array();
foreach ($values as $k => $v) {
if (!is_array($v)) {
$v = array($v);
}
$ors = array();
foreach ($v as $value) {
if (substr($value, -1) == '%') {
$value = substr($value, 0, -1);
$ors[] = new Kwf_Model_Select_Expr_Equal($k, $value);
$ors[] = new Kwf_Model_Select_Expr_Like($k, $value . '-%');
$ors[] = new Kwf_Model_Select_Expr_Like($k, $value . '_%');
} else {
if (strpos($value, '%') !== false) {
$ors[] = new Kwf_Model_Select_Expr_Like($k, $value . '_%');
} else {
$ors[] = new Kwf_Model_Select_Expr_Equal($k, $value);
}
}
}
$and[] = new Kwf_Model_Select_Expr_Or($ors);
}
if ($and) {
$and = new Kwf_Model_Select_Expr_And($and);
if (!in_array($and, $or)) {
$or[] = $and;
}
}
}
}
}
$select = new Kwf_Model_Select();
if ($or) {
$select->where($or[0]);
unset($or[0]);
foreach ($or as $i) {
$s = new Kwf_Model_Select();
$s->where($i);
$select->union($s);
}
}
$select->whereEquals('deleted', false);
return $select;
}