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


PHP Select::offset方法代码示例

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


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

示例1: getList

 public function getList($where = array(), $order = null, $offset = null, $limit = null)
 {
     if (empty($where['ProductFilterOption.productCategoryFilterOptionID'])) {
         $select = new Select();
         $select->from(array('b' => 'Product'));
         $select->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName'));
         $select->where($where);
         $select->offset($offset);
         $select->limit($limit);
         $select->order($order);
     } else {
         $select = $this->getSelect();
         $select->columns(array())->join(array('b' => 'Product'), 'ProductFilterOption.productID = b.productID')->join(array('c' => 'ProductCategory'), 'b.productCategoryID = c.productCategoryID', array('categoryName'))->where($where)->offset($offset)->limit($limit)->group(array('ProductFilterOption.productID'))->having('count(ProductFilterOption.productID) > ' . (count($where['ProductFilterOption.productCategoryFilterOptionID']) - 1));
         $select->order($order);
     }
     $paginator = $this->paginate($select);
     $paginator->setCurrentPageNumber(ceil($offset / $limit) + 1);
     //$paginator->setItemCountPerPage(1);
     $products = $paginator->getCurrentItems()->getArrayCopy();
     $pages = $paginator->getPages();
     $productsCount = $paginator->getTotalItemCount();
     foreach ($products as $k => $v) {
         $products[$k]['leftTime'] = Utility::getLeftTime(time(), $v['endTime']);
     }
     return array('products' => $products, 'productsCount' => $productsCount, 'pages' => $pages);
 }
开发者ID:onlineshine,项目名称:myzf,代码行数:26,代码来源:ProductFilterOption.php

示例2: fetchPostsByFeeds

 public function fetchPostsByFeeds($feeds, $offset = null, $limit = null)
 {
     $select = new Select(self::$_tableName);
     if (!is_null($offset)) {
         $select->offset($offset);
     }
     if (!is_null($limit)) {
         $select->limit($limit);
     }
     $select->join('directus_social_feeds', 'directus_social_feeds.id = directus_social_posts.feed', ['feed_type' => 'type'])->order('directus_social_posts.datetime DESC');
     $select->where->equalTo('directus_social_posts.status', 1)->equalTo('directus_social_feeds.status', 1);
     $FeedWhere = new Where();
     $SocialCache = new SocialCache();
     foreach ($feeds as $feed) {
         // Run scrape if due
         $SocialCache->scrapeFeedIfDue($feed['name'], $feed['type']);
         $FeedWhere->or->nest->equalTo('directus_social_feeds.name', $feed['name'])->equalTo('directus_social_feeds.type', $feed['type'])->unnest;
         $select->where($FeedWhere);
     }
     $socialPosts = $this->selectWith($select);
     $socialPosts = $socialPosts->toArray();
     // Unserialize cached feed entry API-responses
     foreach ($socialPosts as &$post) {
         $post['data'] = json_decode($post['data'], true);
     }
     return $socialPosts;
 }
开发者ID:YounessTayer,项目名称:directus,代码行数:27,代码来源:DirectusSocialPostsTableGateway.php

示例3: fetchAll

 public function fetchAll($columns = null, $where = null, $limit = null, $offset = null)
 {
     $select = new Select();
     $select->from($this->getTable());
     if ($columns) {
         $select->columns($columns);
     }
     if ($where) {
         $select->where($where);
     }
     if ($limit) {
         $select->limit((int) $limit);
     }
     if ($offset) {
         $select->offset((int) $offset);
     }
     return $this->selectWith($select);
 }
开发者ID:jkhaled,项目名称:ZendSkeletonApplication-1,代码行数:18,代码来源:TableGateway.php

示例4: getPostsByDate

 public function getPostsByDate($threadId, $pageNo = 1)
 {
     $selectPost = new Select();
     $selectPost->from('post');
     $selectPost->group('user_id');
     $selectPost->columns(['user_id', 'postcount' => new Expression('COUNT(user_id)')]);
     $predicate = new Predicate(null, Predicate::OP_AND);
     $predicate->equalTo('thread_id', $threadId);
     $select = new Select();
     $select->from($this->tableName);
     $select->order('date_added ASC');
     $select->join(['po' => $selectPost], 'post.user_id = po.user_id', [], $select::JOIN_LEFT . ' ' . $select::JOIN_OUTER);
     $select->join('user', 'user.user_id = post.user_id', [], $select::JOIN_LEFT . ' ' . $select::JOIN_OUTER);
     $select->limit(20);
     $select->offset(($pageNo - 1) * 20);
     $select->columns(['id', 'date_added', 'content', 'last_updated', 'username' => new Expression('user.username'), 'user_title' => new Expression('user.title'), 'user_avatar' => new Expression('user.avatar'), 'user_signature' => new Expression('user.post_signature'), 'user_joined' => new Expression('user.date_joined'), 'user_postcount' => new Expression('po.postcount')], false);
     $select->where($predicate);
     $result = $this->select($select);
     return $result->toArray();
 }
开发者ID:galaco,项目名称:chatter,代码行数:20,代码来源:Post.php

示例5: getThreadsByDate

 public function getThreadsByDate($threadId, $pageNo = 1)
 {
     $selectPost = new Select();
     $selectPost->join('user', 'post.user_id = user.user_id', [], $selectPost::JOIN_LEFT . ' ' . $selectPost::JOIN_OUTER);
     $selectPost->from('post')->group('thread_id');
     $selectPost->columns(['thread_id', 'count' => new Expression('COUNT(thread_id)'), 'last_post' => new Expression('MAX(date_added)'), 'poster' => new Expression('username')]);
     $predicate = new Predicate(null, Predicate::OP_AND);
     $predicate->equalTo('forum_id', $threadId)->equalTo('deleted', '0');
     $select = new Select();
     $select->from($this->tableName);
     $select->order('date_updated DESC');
     $select->limit(20);
     $select->join('user', 'thread.user_id = user.user_id', [], $select::JOIN_LEFT . ' ' . $select::JOIN_OUTER);
     $select->join(['po' => $selectPost], 'thread.id = po.thread_id', [], $select::JOIN_LEFT . ' ' . $select::JOIN_OUTER);
     $select->columns(['id', 'title', 'date_added', 'forum_id', 'view_count', 'sticky', 'post_count' => new Expression('count'), 'creator' => new Expression('username'), 'last_poster' => new Expression('poster'), 'last_post_date' => new Expression('last_post')]);
     $select->offset(($pageNo - 1) * 20);
     $select->where($predicate);
     $result = $this->select($select);
     return $result->toArray();
 }
开发者ID:galaco,项目名称:chatter,代码行数:20,代码来源:Thread.php

示例6: testReset

 /**
  * @testdox unit test: Test reset() resets internal stat of Select object, based on input
  * @covers Zend\Db\Sql\Select::reset
  */
 public function testReset()
 {
     $select = new Select();
     // table
     $select->from('foo');
     $this->assertEquals('foo', $select->getRawState(Select::TABLE));
     $select->reset(Select::TABLE);
     $this->assertNull($select->getRawState(Select::TABLE));
     // columns
     $select->columns(array('foo'));
     $this->assertEquals(array('foo'), $select->getRawState(Select::COLUMNS));
     $select->reset(Select::COLUMNS);
     $this->assertEmpty($select->getRawState(Select::COLUMNS));
     // joins
     $select->join('foo', 'id = boo');
     $this->assertEquals(array(array('name' => 'foo', 'on' => 'id = boo', 'columns' => array('*'), 'type' => 'inner')), $select->getRawState(Select::JOINS));
     $select->reset(Select::JOINS);
     $this->assertEmpty($select->getRawState(Select::JOINS));
     // where
     $select->where('foo = bar');
     $where1 = $select->getRawState(Select::WHERE);
     $this->assertEquals(1, $where1->count());
     $select->reset(Select::WHERE);
     $where2 = $select->getRawState(Select::WHERE);
     $this->assertEquals(0, $where2->count());
     $this->assertNotSame($where1, $where2);
     // group
     $select->group(array('foo'));
     $this->assertEquals(array('foo'), $select->getRawState(Select::GROUP));
     $select->reset(Select::GROUP);
     $this->assertEmpty($select->getRawState(Select::GROUP));
     // having
     $select->having('foo = bar');
     $having1 = $select->getRawState(Select::HAVING);
     $this->assertEquals(1, $having1->count());
     $select->reset(Select::HAVING);
     $having2 = $select->getRawState(Select::HAVING);
     $this->assertEquals(0, $having2->count());
     $this->assertNotSame($having1, $having2);
     // limit
     $select->limit(5);
     $this->assertEquals(5, $select->getRawState(Select::LIMIT));
     $select->reset(Select::LIMIT);
     $this->assertNull($select->getRawState(Select::LIMIT));
     // offset
     $select->offset(10);
     $this->assertEquals(10, $select->getRawState(Select::OFFSET));
     $select->reset(Select::OFFSET);
     $this->assertNull($select->getRawState(Select::OFFSET));
     // order
     $select->order('foo asc');
     $this->assertEquals(array('foo asc'), $select->getRawState(Select::ORDER));
     $select->reset(Select::ORDER);
     $this->assertNull($select->getRawState(Select::ORDER));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:59,代码来源:SelectTest.php

示例7: offset

 /**
  * @param int $offset
  * @return $this
  */
 public function offset($offset)
 {
     $this->select->offset($offset);
     return $this;
 }
开发者ID:t4web,项目名称:infrastructure,代码行数:9,代码来源:Criteria.php

示例8: offset

 /**
  * {@inheritdoc}
  */
 public function offset($offset)
 {
     parent::offset((int) $offset);
     return $this;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:8,代码来源:Select.php

示例9: serendipity_db_limit

/**
 * Returns the option to a LIMIT SQL statement, because it varies accross DB systems
 *
 * @access public
 * @param  int      Number of the first row to return data from
 * @param  int      Number of rows to return
 * @return string   SQL string to pass to a LIMIT statement
 */
function serendipity_db_limit($offset, $limit)
{
    global $serendipity;
    $sql = new Sql($serendipity['dbConn']);
    $select = new Select();
    $select->limit($limit);
    $select->offset($offset);
    return str_replace("LIMIT", "", $sql->getSqlStringForSqlObject($select));
    # TODO: Find a way to not hardcode the LIMIT here
}
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:18,代码来源:generic.inc.php

示例10: assignOptions

 /**
  *
  * @param Select $select
  * @param Options $options
  * @return Select
  */
 protected function assignOptions(Select $select, Options $options)
 {
     if ($options->hasLimit()) {
         $select->limit($options->getLimit());
         if ($options->hasOffset()) {
             $select->offset($options->getOffset());
         }
         $select->quantifier(new Expression('SQL_CALC_FOUND_ROWS'));
     }
     return $select;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:17,代码来源:SqlSource.php

示例11: getSelectInfo

 /**
  * 根据columns主要信息
  */
 function getSelectInfo($where = array(), $order = array(), $limit = '', $offset = '')
 {
     $select = new Select();
     $select->from($this->getTable())->columns($this->selectColumns);
     empty($where) ?: $select->where($where);
     empty($limit) ?: $select->limit((int) $limit);
     empty($offset) ?: $select->offset((int) $offset);
     empty($order) ? $select->order(array($this->_primary => 'desc')) : $select->order($order);
     return $this->selectWith($select)->toArray();
 }
开发者ID:onlineshine,项目名称:myzf,代码行数:13,代码来源:Model.php

示例12: fetchDisappOnlineNow

 public function fetchDisappOnlineNow()
 {
     $select = new Select("camgirls_all");
     $select->where(array('unixtime_last>unix_timestamp()-300'));
     $select->where(array('status="disapp"'));
     $select->order("unixtime_last DESC");
     $select->offset(0);
     $select->limit(20);
     $resultSet = $this->selectWith($select);
     return $this->arrWrapper($resultSet);
 }
开发者ID:nowarena,项目名称:zf2NowArena,代码行数:11,代码来源:CamTable.php

示例13: setSelectLimitOffset

 protected function setSelectLimitOffset(Select $selectSQL, Query $query)
 {
     $limits = $query->getLimit();
     $limit = !$limits ? self::LIMIT_INFINITY : $limits->getLimit();
     $offset = !$limits ? 0 : $limits->getOffset();
     if ($limit != self::LIMIT_INFINITY) {
         $selectSQL->limit($limit);
     }
     if ($offset != 0) {
         $selectSQL->offset($offset);
     }
     return $selectSQL;
 }
开发者ID:avz-cmf,项目名称:zaboy-rest,代码行数:13,代码来源:DbTable.php

示例14: offset

 public function offset($offset)
 {
     return $this->zendSelect->offset($offset);
 }
开发者ID:t4web,项目名称:base,代码行数:4,代码来源:Select.php

示例15: fetchCount

 protected function fetchCount(Select $select)
 {
     $select->limit(1);
     $select->offset(null);
     //NOTE: no method could reset order here
     //$select->order(array());
     $select->reset('order');
     $countColumnName = self::ROW_COUNT_COLUMN;
     if ($this->primaryKey && is_string($this->primaryKey)) {
         $select->columns(array($countColumnName => new Expression("COUNT({$this->primaryKey})")));
     } else {
         $select->columns(array($countColumnName => new Expression('COUNT(*)')));
     }
     //p($select->getSqlString());
     $resultSet = $this->selectWith($select);
     if (false === $this->enableCount) {
         $this->lastSelectString = $select->getSqlString();
         $this->reset();
     }
     if (!$resultSet) {
         return 0;
     }
     $resultSet = $resultSet->current();
     return $this->lastSelectCount = $resultSet->{$countColumnName};
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:25,代码来源:TableGateway.php


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