本文整理汇总了PHP中Kwf_Model_Select类的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Select类的具体用法?PHP Kwf_Model_Select怎么用?PHP Kwf_Model_Select使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kwf_Model_Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: orderConfirmed
public function orderConfirmed(Kwc_Shop_Cart_Order $order)
{
if (!$order->voucher_code) {
return;
}
$c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($order->checkout_component_id);
foreach ($c->getComponent()->getSumRows($order) as $sumRow) {
if (isset($sumRow['type']) && $sumRow['type'] == 'voucher') {
$s = new Kwf_Model_Select();
$s->whereEquals('code', $order->voucher_code);
$row = Kwf_Model_Abstract::getInstance('Kwc_Shop_Cart_Plugins_Voucher_Vouchers')->getRow($s);
$remainingAmount = $row->amount - $row->used_amount + $sumRow['amount'];
$h = $row->createChildRow('history');
$h->amount = -$sumRow['amount'];
$h->order_id = $order->id;
$h->date = $order->date;
$h->comment = trlKwf('Order') . ' ' . $order->order_number;
$h->save();
//verbrauchten betrag auch noch bei der order speichern
$order->voucher_amount = (double) $h->amount;
$order->voucher_remaining_amount = (double) $remainingAmount;
$order->save();
break;
}
}
}
示例2: testChildCountEager
public function testChildCountEager()
{
$s = new Kwf_Model_Select();
$s->whereId(1);
$s->expr('parent_child_count');
$this->_modelChild->getRow($s)->parent_child_count;
}
示例3: _getLanguageRow
protected function _getLanguageRow($parentData)
{
$s = new Kwf_Model_Select();
$s->whereEquals('domain', $parentData->id);
$s->whereEquals('master', 1);
return $this->_getModel()->getRow($s);
}
示例4: testIgnoreDeleted
public function testIgnoreDeleted()
{
$model = Kwf_Model_Abstract::getInstance('Kwf_Model_Union_DeletedFlag_TestModel');
$s = new Kwf_Model_Select();
$s->ignoreDeleted();
$this->assertEquals($model->countRows($s), 3);
}
示例5: getFavouriteComponentIds
/**
* returns a list of all visible favourite componentIds
*/
public static function getFavouriteComponentIds($favouritesModel)
{
$ret = array();
$userId = Kwf_Registry::get('userModel')->getAuthedUserId();
if ($userId) {
$cacheIdUser = 'favCIds' . $userId;
$ret = Kwf_Cache_Simple::fetch($cacheIdUser, $success);
if (!$success) {
// get all favourites related to user
$select = new Kwf_Model_Select();
$select->whereEquals('user_id', $userId);
$favouritesModel = Kwf_Model_Abstract::getInstance($favouritesModel);
$favourites = $favouritesModel->getRows($select);
$componentIds = array();
foreach ($favourites as $favourite) {
$component = Kwf_Component_Data_Root::getInstance()->getComponentById($favourite->component_id);
// check if component is visible and existent
if ($component) {
// if component is visible create list of users related to component
$componentIds[] = $component->componentId;
}
}
// cache relation of visible components to user
Kwf_Cache_Simple::add($cacheIdUser, $componentIds);
$ret = $componentIds;
}
}
return $ret;
}
示例6: testParentOrder
public function testParentOrder()
{
$s = new Kwf_Model_Select();
$s->order('if_field', 'DESC');
$row = $this->_modelChild->getRow($s);
$this->assertEquals(207, $row->if_field);
}
示例7: updatePages
public function updatePages($cmp)
{
$s = new Kwf_Model_Select();
$s->whereEquals('component_id', $cmp->dbId);
$rows = $this->getRows($s);
$rowsByTargetPageId = array();
foreach ($rows as $r) {
$rowsByTargetPageId[$r->target_page_id] = $r;
}
$childPagesComponentSelect = array('ignoreVisible' => true);
$pos = 0;
foreach ($cmp->getPage()->getChildPages($childPagesComponentSelect) as $childPage) {
if (is_numeric($childPage->dbId)) {
$id = $childPage->dbId;
} else {
$id = substr(md5($childPage->dbId), 0, 5);
}
$pos++;
if (isset($rowsByTargetPageId[$childPage->dbId])) {
$row = $rowsByTargetPageId[$childPage->dbId];
unset($rowsByTargetPageId[$childPage->dbId]);
} else {
$row = $this->createRow();
$row->target_page_id = $childPage->dbId;
$row->visible = false;
}
$row->child_id = $id;
$row->pos = $pos;
$row->component_id = $cmp->dbId;
$row->save();
}
foreach ($rowsByTargetPageId as $row) {
$row->delete();
}
}
示例8: _getNetworks
private function _getNetworks($currentPage)
{
$networks = array();
foreach (Kwf_Model_Abstract::getInstance('Kwc_Advanced_SocialBookmarks_AvaliableModel')->getRows() as $n) {
$networks[$n->id] = $n->toArray();
}
$s = new Kwf_Model_Select();
$s->order('pos');
$ret = array();
foreach ($this->getRow()->getChildRows('Networks', $s) as $net) {
if (isset($networks[$net->network_id])) {
$icon = '/Kwc/Advanced/SocialBookmarks/Icons/' . $this->_getSetting('iconSet') . '/';
if (file_exists(KWF_PATH . $icon . $net->network_id . '.jpg')) {
$icon .= $net->network_id . '.jpg';
} else {
if (file_exists(KWF_PATH . $icon . $net->network_id . '.png')) {
$icon .= $net->network_id . '.png';
} else {
$icon = false;
}
}
if ($icon) {
$icon = '/assets/kwf' . $icon;
}
$url = str_replace('{0}', $currentPage->getAbsoluteUrl(), $networks[$net->network_id]['url']);
$ret[] = array('id' => $net->network_id, 'name' => $networks[$net->network_id]['name'], 'url' => $url, 'icon' => $icon);
}
}
return $ret;
}
示例9: processInput
public function processInput(array $postData)
{
parent::processInput($postData);
$this->_accessByMailRow = false;
if (isset($postData['key'])) {
$s = new Kwf_Model_Select();
$s->whereEquals('key', $postData['key']);
$s->where(new Kwf_Model_Select_Expr_Higher('date', new Kwf_Date(time() - 24 * 60 * 60)));
$this->_accessByMailRow = Kwf_Model_Abstract::getInstance('Kwf_Component_Plugin_AccessByMail_Model')->getRow($s);
if (!$this->_accessByMailRow) {
$this->_errors[] = array('message' => trlKwf("Invalid or expired Link. Please request a new one."));
} else {
$session = new Kwf_Session_Namespace('kwc_' . $this->getData()->parent->componentId);
$session->login = true;
$session->key = $postData['key'];
}
} else {
$session = new Kwf_Session_Namespace('kwc_' . $this->getData()->parent->componentId);
if ($session->login) {
$s = new Kwf_Model_Select();
$s->whereEquals('key', $session->key);
$this->_accessByMailRow = Kwf_Model_Abstract::getInstance('Kwf_Component_Plugin_AccessByMail_Model')->getRow($s);
}
}
}
示例10: testExprCompareHigherInSelect
public function testExprCompareHigherInSelect()
{
$select = new Kwf_Model_Select();
$select->whereEquals('expr_foo_bar_higher', true);
$count = $this->_modelChild->countRows($select);
$this->assertEquals(2, $count);
}
示例11: update
public function update()
{
parent::update();
$select = new Kwf_Model_Select();
$select->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equals('dimension', 'customcrop'), new Kwf_Model_Select_Expr_Equals('dimension', 'custombestfit'))));
$select->order('dimension', 'asc');
$rows = Kwf_Model_Abstract::getInstance('Kwc_Abstract_Image_Model')->getRows($select);
foreach ($rows as $row) {
if ($row->dimension == 'customcrop') {
$row->dimension = 'custom';
$row->crop_x = null;
$row->crop_y = null;
$row->crop_width = null;
$row->crop_heigth = null;
} else {
if ($row->dimension == 'custombestfit') {
$row->dimension = 'custom';
if ($row->imageExists()) {
$targetSize = array('width' => $row->width, 'height' => $row->height, 'cover' => false);
$outputSize = Kwf_Media_Image::calculateScaleDimensions($row->getParentRow('Image')->getFileSource(), $targetSize);
$row->width = $outputSize['width'];
$row->height = $outputSize['height'];
$row->crop_x = $outputSize['crop']['x'];
$row->crop_y = $outputSize['crop']['y'];
$row->crop_width = $outputSize['crop']['width'];
$row->crop_height = $outputSize['crop']['height'];
}
}
}
$row->save();
}
}
示例12: _getSelect
protected function _getSelect(ParamFetcher $paramFetcher, Request $request)
{
$select = new \Kwf_Model_Select();
$select->limit($paramFetcher->get('limit'), $paramFetcher->get('start'));
$queryValue = trim($request->get('query'));
if ($queryValue) {
$exprs = array();
if (!$this->_queryColumns) {
throw new \Kwf_Exception("_queryColumns are required to be set");
}
if ($this->_querySplit) {
$queryValue = explode(' ', $queryValue);
} else {
$queryValue = array($queryValue);
}
foreach ($queryValue as $q) {
$e = array();
foreach ($this->_queryColumns as $c) {
$e[] = new \Kwf_Model_Select_Expr_Like($c, '%' . $q . '%');
}
if (count($e) > 1) {
$exprs[] = new \Kwf_Model_Select_Expr_Or($e);
} else {
$exprs[] = $e[0];
}
}
if (count($exprs) > 1) {
$select->where(new \Kwf_Model_Select_Expr_And($exprs));
} else {
$select->where($exprs[0]);
}
}
return $select;
}
示例13: 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);
}
示例14: getUserToLoginByParams
public function getUserToLoginByParams($redirectBackUrl, array $params)
{
$userData = $this->_getUserDataByParams($redirectBackUrl, $params);
$s = new Kwf_Model_Select();
$s->whereEquals('facebook_user_id', $userData->id);
return $this->_model->getRow($s);
}
示例15: setUp
public function setUp()
{
parent::setUp();
$select = new Kwf_Model_Select();
$select->whereEquals('active', 1);
$this->_model = new Kwf_Model_Union(array('models' => array('a' => 'Kwf_Model_Union_MergeSelect_Model1', 'b' => array('model' => 'Kwf_Model_Union_MergeSelect_Model2', 'select' => $select)), 'columnMapping' => 'Kwf_Model_Union_MergeSelect_TestMapping'));
}