本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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));
}
示例7: offset
/**
* @param int $offset
* @return $this
*/
public function offset($offset)
{
$this->select->offset($offset);
return $this;
}
示例8: offset
/**
* {@inheritdoc}
*/
public function offset($offset)
{
parent::offset((int) $offset);
return $this;
}
示例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
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例14: offset
public function offset($offset)
{
return $this->zendSelect->offset($offset);
}
示例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};
}