本文整理汇总了PHP中Kwf_Model_Select::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Select::where方法的具体用法?PHP Kwf_Model_Select::where怎么用?PHP Kwf_Model_Select::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Model_Select
的用法示例。
在下文中一共展示了Kwf_Model_Select::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: 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();
}
}
示例3: 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);
}
}
}
示例4: buildSelect
public function buildSelect(Request $request, array $options = array())
{
$select = new \Kwf_Model_Select();
if ($request->get('limit')) {
$select->limit($request->get('limit'), $request->get('start'));
} else {
$select->limit(25, $request->get('start'));
}
$queryValue = trim($request->get('query'));
if ($queryValue) {
$queryColumns = null;
if (isset($options['queryColumns'])) {
$queryColumns = $options['queryColumns'];
}
$exprs = array();
if (!$queryColumns) {
throw new \Kwf_Exception("queryColumns are required to be set");
}
if (isset($options['querySplit']) && $options['querySplit']) {
$queryValue = explode(' ', $queryValue);
} else {
$queryValue = array($queryValue);
}
foreach ($queryValue as $q) {
$e = array();
foreach ($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]);
}
}
$restColumns = $this->model->getSerializationColumns(array('rest_read', 'rest'));
$exprColumns = $this->model->getExprColumns();
foreach (array_intersect(array_keys($restColumns), $exprColumns) as $i) {
$select->expr($i);
}
return $select;
}
示例5: getAuthedUser
public function getAuthedUser()
{
//return first user
$select = new Kwf_Model_Select();
$select->where(new Kwf_Model_Select_Expr_Equal('id', $this->_authedUserId));
$row = $this->getRow($select);
return $row;
}
示例6: testUpdateRowsIgnoreDeleted
public function testUpdateRowsIgnoreDeleted()
{
$model = $this->_m;
$model->getRow(1)->delete();
$s = new Kwf_Model_Select(array('ignoreDeleted' => true));
$s->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equals('id', 1), new Kwf_Model_Select_Expr_Equals('id', 2))));
$model->updateRows(array('foo' => 'newBar'), $s);
$this->assertEquals('newBar', $model->getRow(2)->foo);
}
示例7: _fetchRedirectUrl
private function _fetchRedirectUrl($type, $source, $host)
{
$s = new Kwf_Model_Select();
$s->whereEquals('type', $type);
$source = rtrim($source, '/');
if ($type == 'domain' || $type == 'domainPath') {
$sourceWithoutWww = preg_replace('#^www\\.#', '', $source);
$sources = array($source, 'http://' . $source, $source . '/', 'http://' . $source . '/', $sourceWithoutWww, 'http://' . $sourceWithoutWww, $sourceWithoutWww . '/', 'http://' . $sourceWithoutWww . '/');
$s->whereEquals('source', $sources);
} else {
if (substr($source, 0, 6) == '/media') {
$parts = explode('/', $source);
if (isset($parts[6])) {
$source = str_replace($parts[6], '%', $source);
}
$s->where(new Kwf_Model_Select_Expr_Like('source', $source));
} else {
$sources = array($source, $source . '/');
$s->whereEquals('source', $sources);
}
}
$s->whereEquals('active', true);
if ($type == 'path') {
if ($root = Kwf_Component_Data_Root::getInstance()) {
$domainComponents = $root->getDomainComponents(array('ignoreVisible' => true));
if (count($domainComponents) > 1) {
$path = $root->getComponent()->formatPath(array('host' => $host, 'path' => ''));
if (!is_null($path)) {
$path = trim($path, '/');
$component = $root->getComponent()->getPageByUrl($path, null);
if ($component) {
$s->whereEquals('domain_component_id', $component->getDomainComponent()->dbId);
} else {
return null;
}
} else {
return null;
}
}
}
}
$row = $this->getRow($s);
$target = null;
if ($row) {
if ($row->target_type == 'extern') {
$target = $row->target;
} else {
if ($row->target_type == 'intern' || $row->target_type == 'downloadTag') {
$c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->target);
if ($c) {
$target = $c->getAbsoluteUrl();
}
}
}
}
return $target;
}
示例8: testChildContains2
public function testChildContains2()
{
$model = Kwf_Model_Abstract::getInstance('Kwf_Model_Union_Dependent_Parent');
$childSelect = new Kwf_Model_Select();
$childSelect->whereEquals('foo', 'xx');
$select = new Kwf_Model_Select();
$select->where(new Kwf_Model_Select_Expr_Child_Contains('TestModel', $childSelect));
$this->assertEquals(2, count($model->getRows($select)));
$this->assertEquals(2, $model->countRows($select));
}
示例9: testChildReference
public function testChildReference()
{
$select = new Kwf_Model_Select();
$select->where(new Kwf_Model_Select_Expr_Parent('Parent', new Kwf_Model_Select_Expr_Equal('foo', 5)));
$rows = $this->_modelChild->getRows($select);
$this->assertEquals(count($rows), 3);
foreach ($rows as $row) {
$this->assertEquals($row->getParentRow('Parent')->foo, 5);
}
}
示例10: testChildContains
public function testChildContains()
{
$select = new Kwf_Model_Select();
$childSelect = new Kwf_Model_Select();
$childSelect->whereEquals('bar', 5);
$s = new Kwf_Model_Select();
$s->where(new Kwf_Model_Select_Expr_Child_Contains('Reference1', $childSelect));
$foo = $this->_modelFoo->getRow($s);
$this->assertEquals('5', $foo->foo);
}
示例11: testToArrayFromArray
public function testToArrayFromArray()
{
$select = new Kwf_Model_Select();
$select->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equals('foo', 'bar'), new Kwf_Model_Select_Expr_Not(new Kwf_Model_Select_Expr_Equals('baz', 'buz')))));
$select->whereEquals('blub', 123);
$ar = $select->toArray();
$this->assertEquals(is_array($ar), true);
$select2 = Kwf_Model_Select::fromArray($ar);
$this->assertEquals($select, $select2);
}
示例12: _initFields
protected function _initFields()
{
$fs = $this->_form;
$sel = new Kwf_Model_Select();
$sel->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equal('id', 1), new Kwf_Model_Select_Expr_Equal('id', 2))));
$fs->add(new Kwf_Form_Field_MultiCheckbox('Relation', 'Value', 'Relations only'))->setValuesSelect($sel);
$sel = new Kwf_Model_Select();
$sel->whereEquals('id', 3);
$fs->add(new Kwf_Form_Field_MultiCheckbox(Kwf_Model_Abstract::getInstance('Kwf_Form_MultiCheckbox_RelationModel'), 'Value', 'Model and relation'))->setValuesSelect($sel);
$fs->add(new Kwf_Form_Field_MultiCheckbox(Kwf_Model_Abstract::getInstance('Kwf_Form_MultiCheckbox_RelationModelNoRel'), 'Value', 'Model and relation (no dataToRelation)'));
$fs->add(new Kwf_Form_Field_MultiCheckbox('Relation', 'Value', 'setShowCheckAllLinks(false)'))->setShowCheckAllLinks(false);
}
示例13: onRowUpdatesFinished
public function onRowUpdatesFinished(Kwf_Events_Event_Row_UpdatesFinished $event)
{
if (count($this->_orExpr->getExpressions())) {
$select = new Kwf_Model_Select();
$select->where($this->_orExpr);
$rows = Kwf_Component_Cache::getInstance()->getModel('url')->export(Kwf_Model_Abstract::FORMAT_ARRAY, $select);
foreach ($rows as $row) {
$cacheId = 'url-' . $row['url'];
Kwf_Cache_Simple::delete($cacheId);
}
}
}
示例14: jsonClearViewCacheAction
public function jsonClearViewCacheAction()
{
$select = new Kwf_Model_Select();
if ($this->_getParam('dbId')) {
$select->where(new Kwf_Model_Select_Expr_Like('db_id', $this->_getParam('dbId')));
}
if ($this->_getParam('id')) {
$select->where(new Kwf_Model_Select_Expr_Like('component_id', $this->_getParam('id')));
}
if ($this->_getParam('expandedId')) {
$select->where(new Kwf_Model_Select_Expr_Like('expanded_component_id', $this->_getParam('expandedId')));
}
if ($this->_getParam('class')) {
$c = $this->_getParam('class');
if (strpos($c, '%') === false) {
$whereClass = array($c);
foreach (Kwc_Abstract::getComponentClasses() as $cls) {
if (in_array($c, Kwc_Abstract::getSetting($cls, 'parentClasses'))) {
$whereClass[] = $cls;
}
}
$select->whereEquals('component_class', $whereClass);
} else {
$select->where(new Kwf_Model_Select_Expr_Like('component_class', $this->_getParam('class')));
}
}
if ($this->_getParam('type')) {
$select->where(new Kwf_Model_Select_Expr_Like('type', $this->_getParam('type')));
}
$select->whereEquals('deleted', false);
$model = Kwf_Component_Cache::getInstance()->getModel();
$this->view->entries = $model->countRows($select);
if (!$this->view->entries) {
throw new Kwf_Exception_Client("No active view cache entries found; nothing to do.");
}
if ($this->_getParam('force')) {
Kwf_Component_Cache::getInstance()->deleteViewCache($select);
}
}
示例15: onStylesRowUpdate
public function onStylesRowUpdate(Kwf_Events_Event_Row_Updated $e)
{
$s = new Kwf_Model_Select();
$s->whereEquals('uses_styles', true);
$s->where(new Kwf_Model_Select_Expr_Like('content', '%class="style' . $e->row->id . '"%'));
$rows = Kwc_Basic_Text_Component::createOwnModel($this->_class)->export(Kwf_Model_Interface::FORMAT_ARRAY, $s, array('columns' => array('component_id')));
foreach ($rows as $row) {
foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($row['component_id']) as $c) {
if ($c->componentClass == $this->_class) {
$this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $c));
}
}
}
}