本文整理汇总了PHP中Kwf_Model_Select::order方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Model_Select::order方法的具体用法?PHP Kwf_Model_Select::order怎么用?PHP Kwf_Model_Select::order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Model_Select
的用法示例。
在下文中一共展示了Kwf_Model_Select::order方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplateVars
public function getTemplateVars()
{
$ret = parent::getTemplateVars();
$ret['settingsRow'] = $this->_getRow();
$ret['tableStyle'] = $this->_getRow()->table_style;
$ret['columnCount'] = $this->getColumnCount();
if (Kwf_Config::getValue('kwc.responsive')) {
$ret['cssClass'] .= ' responsive' . ucfirst($this->_getRow()->responsive_style);
}
$dataSelect = new Kwf_Model_Select();
$dataSelect->whereEquals('visible', 1);
$dataSelect->order('pos', 'ASC');
$ret['dataRows'] = array();
$rows = $this->_getRow()->getChildRows('tableData', $dataSelect);
foreach ($rows as $row) {
$rowData = array();
$rowData['cssStyle'] = $row->css_style;
$rowData['data'] = array();
for ($i = 1; $i <= $ret['columnCount']; $i++) {
$rowData['data']['column' . $i] = array('value' => $row->{'column' . $i}, 'cssClass' => '');
}
$ret['dataRows'][] = $rowData;
}
$ret['dataRows'] = Kwc_Basic_Table_Component::addDefaultCssClasses($ret['dataRows'], $this->_getSetting('rowStyles'));
$ret['headerRows'] = array();
if (isset($ret['dataRows'][0]['htmlTag']) && $ret['dataRows'][0]['htmlTag'] == 'th') {
$ret['headerRows'] = array(array_shift($ret['dataRows']));
}
return $ret;
}
示例2: 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);
}
示例3: 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();
}
}
示例4: _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;
}
示例5: __get
public function __get($name)
{
if ($name == 'name' || $name == 'col_span' || $name == 'total_columns' || $name == 'columns') {
if (!isset($this->_rows)) {
$select = new Kwf_Model_Select();
$select->whereEquals('component_id', $this->component_id);
$select->order('pos');
$this->_rows = $this->getModel()->getRows($select);
}
$columnTypes = Kwc_Abstract::getSetting($this->getModel()->getComponentClass(), 'columns');
$typeName = array_keys($columnTypes);
$typeName = array_shift($typeName);
if ($parentRow = $this->getParentRow('Component')) {
$typeName = $parentRow->type;
}
$type = $columnTypes[$typeName];
if ($name == 'columns') {
return array_sum($type['colSpans']);
}
if ($name == 'total_columns') {
return count($type['colSpans']);
}
unset($columnTypes);
$i = 0;
$countInvisible = 0;
foreach ($this->_rows as $row) {
if (!$row->visible) {
$countInvisible++;
$i++;
if ($this == $row) {
if ($name == 'name') {
return trlKwf('Invisible');
} else {
if ($name == 'col_span') {
return max($type['colSpans']);
}
}
} else {
continue;
}
}
$number = $i - $countInvisible;
while ($number >= count($type['colSpans'])) {
$number -= count($type['colSpans']);
}
if ($this == $row) {
if ($name == 'name') {
return trlKwf('Column {0}, width {1}%', array($number + 1, floor($type['colSpans'][$number] / array_sum($type['colSpans']) * 100)));
} else {
if ($name == 'col_span') {
return $type['colSpans'][$number];
}
}
}
$i++;
}
}
return parent::__get($name);
}
示例6: testOrder
public function testOrder()
{
$s = new Kwf_Model_Select();
$s->whereEquals('id', 1);
$s->order('foo');
$row = $this->_modelChild->getRow($s);
$this->assertEquals($row->foo, 777);
}
示例7: testChildSumWithExpressionOrderLazy
public function testChildSumWithExpressionOrderLazy()
{
$select = new Kwf_Model_Select();
$s = new Kwf_Model_Select();
$s->order('foo_value_sum', 'DESC');
$row = $this->_modelBar->getRow($s);
$sum = $row->foo_value_sum;
$this->assertEquals(6, $sum);
}
示例8: getSettings
public static function getSettings()
{
$ret = parent::getSettings();
$ret['generators']['content'] = array('class' => 'Kwf_Component_Generator_Static', 'component' => 'Kwc_Newsletter_Detail_Mail_Paragraphs_Component');
$select = new Kwf_Model_Select();
$select->whereEquals('unsubscribed', false);
$select->whereEquals('activated', true);
$select->order('id', 'ASC');
$ret['recipientSources'] = array('n' => array('model' => 'Kwc_Newsletter_Subscribe_Model', 'select' => $select));
$ret['trackViews'] = true;
return $ret;
}
示例9: testGetRowsWithExprOrder
public function testGetRowsWithExprOrder()
{
$s = new Kwf_Model_Select();
$s->order('baz');
$rows = $this->_m->getRows($s);
$this->assertEquals(6, count($rows));
$this->assertEquals('2', $rows[0]->baz);
$this->assertEquals('cc', $rows[1]->baz);
$this->assertEquals('cc3', $rows[2]->baz);
$this->assertEquals('foobar', $rows[3]->baz);
$this->assertEquals('foobar', $rows[4]->baz);
$this->assertEquals('foobar', $rows[5]->baz);
}
示例10: _getChildPageIds
private function _getChildPageIds($parentId)
{
$cacheId = 'pcIds-' . $parentId;
$ret = Kwf_Cache_Simple::fetch($cacheId);
if ($ret === false) {
Kwf_Benchmark::count('GenPage::query', 'childIds(' . $parentId . ')');
$select = new Kwf_Model_Select();
if (is_numeric($parentId)) {
$select->whereEquals('parent_id', $parentId);
} else {
$select->where(new Kwf_Model_Select_Expr_Like('parent_id', $parentId . '%'));
}
$select->order('pos');
$rows = $this->_getModel()->export(Kwf_Model_Interface::FORMAT_ARRAY, $select, array('columns' => array('id')));
$ret = array();
foreach ($rows as $row) {
$ret[] = $row['id'];
}
Kwf_Cache_Simple::add($cacheId, $ret);
}
return $ret;
}
示例11: _getFormField
protected function _getFormField()
{
$ret = new Kwf_Form_Field_Select($this->getData()->componentId);
$ret->setFieldLabel($this->getRow()->field_label);
if ($this->getRow()->label_width) {
$ret->setLabelWidth($this->getRow()->label_width);
}
$ret->setWidth($this->getRow()->width);
$ret->setAllowBlank(!$this->getRow()->required);
$ret->setHideLabel($this->getRow()->hide_label);
$values = array();
$s = new Kwf_Model_Select();
$s->order('pos');
foreach ($this->getRow()->getChildRows('Values', $s) as $i) {
$values[$i->value] = $i->value;
}
$ret->setValues($values);
if ($this->getRow()->label_position_above) {
$ret->setLabelPosition('above');
}
return $ret;
}
示例12: 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')));
}
示例13: select
public function select($where = array(), $order = null, $limit = null, $start = null)
{
if (!is_array($where)) {
$ret = new Kwf_Model_Select();
if ($where) {
$ret->whereEquals($this->getPrimaryKey(), $where);
}
} else {
$ret = new Kwf_Model_Select($where);
}
if ($order) {
$ret->order($order);
}
if ($limit || $start) {
$ret->limit($limit, $start);
}
return $ret;
}
示例14: _getPageIds
protected function _getPageIds($parentData, $select)
{
if (!$parentData && ($p = $select->getPart(Kwf_Component_Select::WHERE_CHILD_OF))) {
if ($p->getPage()) {
$p = $p->getPage();
}
$parentData = $p;
}
$pageIds = array();
if ($parentData && !$select->hasPart(Kwf_Component_Select::WHERE_ID)) {
// diese Abfragen sind implizit recursive=true
$parentId = $parentData->dbId;
if ($select->getPart(Kwf_Component_Select::WHERE_HOME)) {
$s = new Kwf_Model_Select();
$s->whereEquals('is_home', true);
$s->whereEquals('parent_subroot_id', $parentData->getSubroot()->dbId);
//performance to look only in subroot - correct filterting done below
Kwf_Benchmark::count('GenPage::query', 'home');
$rows = $this->_getModel()->export(Kwf_Model_Interface::FORMAT_ARRAY, $s, array('columns' => array('id')));
$homePages = array();
foreach ($rows as $row) {
$homePages[] = $row['id'];
}
foreach ($homePages as $pageId) {
$pd = $this->_getPageData($pageId);
if (substr($pd['parent_id'], 0, strlen($parentId)) == $parentId) {
$pageIds[] = $pageId;
continue;
}
foreach ($pd['parent_ids'] as $pageParentId) {
if ($pageParentId == $parentId) {
$pageIds[] = $pageId;
break;
}
}
}
} else {
if ($select->hasPart(Kwf_Component_Select::WHERE_FILENAME)) {
$filename = $select->getPart(Kwf_Component_Select::WHERE_FILENAME);
$cacheId = 'pcFnIds-' . $parentId . '-' . $filename;
$pageIds = Kwf_Cache_Simple::fetch($cacheId);
if ($pageIds === false) {
$s = new Kwf_Model_Select();
$s->whereEquals('filename', $filename);
if (is_numeric($parentId)) {
$s->whereEquals('parent_id', $parentId);
} else {
$s->where(new Kwf_Model_Select_Expr_Like('parent_id', $parentId . '%'));
}
Kwf_Benchmark::count('GenPage::query', 'filename');
$rows = $this->_getModel()->export(Kwf_Model_Interface::FORMAT_ARRAY, $s, array('columns' => array('id')));
$pageIds = array();
foreach ($rows as $row) {
$pageIds[] = $row['id'];
}
if ($pageIds) {
Kwf_Cache_Simple::add($cacheId, $pageIds);
} else {
$s->order('date', 'DESC');
$rows = $this->getHistoryModel()->export(Kwf_Model_Interface::FORMAT_ARRAY, $s, array('columns' => array('page_id')));
foreach ($rows as $row) {
$pageIds[] = $row['page_id'];
}
}
}
} else {
if ($select->hasPart(Kwf_Component_Select::WHERE_COMPONENT_CLASSES)) {
$selectClasses = $select->getPart(Kwf_Component_Select::WHERE_COMPONENT_CLASSES);
$keys = array();
foreach ($selectClasses as $selectClass) {
$key = array_search($selectClass, $this->_settings['component']);
if ($key) {
$keys[] = $key;
}
}
$s = new Kwf_Model_Select();
$s->whereEquals('component', array_unique($keys));
if (is_numeric($parentId)) {
$s->whereEquals('parent_id', $parentId);
} else {
$s->where(new Kwf_Model_Select_Expr_Like('parent_id', $parentId . '%'));
}
$s->order('pos');
Kwf_Benchmark::count('GenPage::query', 'component');
$rows = $this->_getModel()->export(Kwf_Model_Interface::FORMAT_ARRAY, $s, array('columns' => array('id')));
foreach ($rows as $row) {
$pageIds[] = $row['id'];
}
} else {
$pageIds = $this->_getChildPageIds($parentId);
}
}
}
} else {
$pagesSelect = new Kwf_Model_Select();
if ($id = $select->getPart(Kwf_Component_Select::WHERE_ID)) {
//query only by id, no db query required
$pageIds = array($id);
if ($sr = $select->getPart(Kwf_Component_Select::WHERE_SUBROOT)) {
$pd = $this->_getPageData($id);
//.........这里部分代码省略.........
示例15: hasContent
public function hasContent()
{
$dataSelect = new Kwf_Model_Select();
$dataSelect->whereEquals('visible', 1);
$dataSelect->order('pos', 'ASC');
$rows = $this->_getRow()->getChildRows('tableData', $dataSelect);
if (count($rows)) {
return true;
} else {
return false;
}
}