本文整理汇总了PHP中Zend\Db\ResultSet\HydratingResultSet::buffer方法的典型用法代码示例。如果您正苦于以下问题:PHP HydratingResultSet::buffer方法的具体用法?PHP HydratingResultSet::buffer怎么用?PHP HydratingResultSet::buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\ResultSet\HydratingResultSet
的用法示例。
在下文中一共展示了HydratingResultSet::buffer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCurrentWillReturnBufferedRow
/**
* @covers Zend\Db\ResultSet\HydratingResultSet::current
*/
public function testCurrentWillReturnBufferedRow()
{
$hydratingRs = new HydratingResultSet();
$hydratingRs->initialize(new \ArrayIterator(array(array('id' => 1, 'name' => 'one'), array('id' => 2, 'name' => 'two'))));
$hydratingRs->buffer();
$obj1 = $hydratingRs->current();
$hydratingRs->rewind();
$obj2 = $hydratingRs->current();
$this->assertSame($obj1, $obj2);
}
示例2: fetchAll
public function fetchAll($blvdId)
{
$select = $this->sql->select();
$select->where(array("blvd_id" => $blvdId));
$statement = $this->sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
$entityPrototype = new BlvdCategoryEntity();
$hydrator = new ClassMethods();
$resultset = new HydratingResultSet($hydrator, $entityPrototype);
$resultset->initialize($results);
$resultset->buffer();
return $resultset;
}
示例3: getLinks
public function getLinks()
{
$select = $this->sql->select();
$select->order(array('sort_order ASC'));
//echo "<br><br>".$select->getSqlString($this->dbAdapter->getPlatform());
$statement = $this->sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
/*
$rows = new ResultSet();
$arr = $rows->initialize($results)->toArray();
printR($arr);
return $arr;
*/
$entityPrototype = new LinkEntity();
$hydrator = new ClassMethods();
$resultset = new HydratingResultSet($hydrator, $entityPrototype);
$resultset->initialize($results);
$resultset->buffer();
return $resultset;
}
示例4: fetchAll
public function fetchAll($topOnly = 1, $bottomOnly = 0, $disabledOnly = 0, $idNameOnly = false)
{
$select = $this->sql->select();
if ($topOnly) {
$select->where(array('top' => 1, 'disabled' => 0));
$select->order(array('sort_order_top ASC'));
} elseif ($bottomOnly) {
$select->where(array('bottom' => 1, 'disabled' => 0));
$select->order(array('sort_order_bottom ASC'));
} elseif ($disabledOnly) {
$select->where(array('disabled' => 1));
}
$statement = $this->sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
$entityPrototype = new BlvdCategoryEntity();
$hydrator = new ClassMethods();
$resultset = new HydratingResultSet($hydrator, $entityPrototype);
$resultset->initialize($results);
$resultset->buffer();
return $resultset;
}
示例5: fetchThumbArr
public function fetchThumbArr($offset, $limit)
{
$select = $this->sql->select();
//$select->where(array('media_url IS NOT NULL'));
$select->where(array('unpublish' => 0));
$select->order('id DESC');
$select->offset($offset);
$select->limit($limit);
$str = $select->getSqlString($this->dbAdapter->getPlatform());
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
if ($result->count() == 0) {
return false;
}
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new VideosEntity());
$resultSet->initialize($result);
$resultSet->buffer();
$thumbArr = array();
$showNextPageLink = 0;
$key = 0;
foreach ($resultSet as $key => $obj) {
$thumbArr[$key]['thumb'] = $obj->getThumbnail();
$thumbArr[$key]['id'] = $obj->getId();
$thumbArr[$key]['title'] = $obj->getTitle();
$thumbArr[$key]['video_id'] = $obj->getVideoId();
$dateYMon = date("Y-M", strtotime($obj->getDateCreated()));
$thumbArr[$key]['dateYMon'] = $dateYMon;
}
if ($limit == $resultSet->count()) {
$showNextPageLink = 1;
}
$key++;
$thumbArr[$key]['nav']['showNextPageLink'] = $showNextPageLink;
$thumbArr[$key]['nav']['page'] = $offset / $limit;
$thumbArr[$key]['nav']['limit'] = $limit;
return $thumbArr;
}
示例6: fetchTwitterUser
public function fetchTwitterUser($screenName)
{
$whereArr = array('screen_name' => $screenName);
$select = $this->sql->select();
$select->where($whereArr);
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute()->current();
//echo "<br><br>\n".$select->getSqlString($this->dbAdapter->getPlatform())."\n";
if (!$result) {
return false;
}
$hydrator = new ClassMethods();
$twitterUser = new TwitterUserEntity();
$hydrator->hydrate($result, $twitterUser);
return $twitterUser;
// this triggers an exception 'getArrayCopy() needed'
// Zend\Stdlib\Hydrator\ArraySerializable::extract expects the provided object to implement getArrayCopy()
$entityPrototype = new TwitterUserEntity();
$hydrator = new ClassMethods();
$resultset = new HydratingResultSet($hydrator, $entityPrototype);
$resultset->initialize($results);
$resultset->buffer();
return $resultset;
}
示例7: getRecentBlvd
public function getRecentBlvd($numCols)
{
// can't get the join to work using zf2 methods, so using raw query
$q = "SELECT * from ";
$q .= "(SELECT `blvd`.*, `blvd_categories`.`category_id` AS `category_id` FROM `blvd` ";
$q .= "INNER JOIN `blvd_categories` ON `blvd_categories`.`blvd_id` = `blvd`.`id` ";
$q .= "INNER JOIN `categories` ON `blvd_categories`.`category_id` = `categories`.`id` ";
$q .= "WHERE `categories`.`disabled` = '0' ";
$q .= "AND categories.top = 1 ";
$q .= "AND blvd_categories.primary = '1' ";
$q .= "ORDER BY `category_id` DESC, `last_social_media_datetime` DESC, blvd_id DESC) ";
$q .= "AS `blvdrows` ";
$q .= "GROUP BY `category_id`";
$statement = $this->dbAdapter->createStatement($q);
$result = $statement->execute();
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new BlvdModel());
$resultSet->initialize($result);
$resultSet->buffer();
$resultSet = $this->addSocialMedia($resultSet, $numCols);
$resultSet = $this->addSecondaryCategory($resultSet);
return $resultSet;
/*
$select = $this->sql->select();
$select->join("blvd_categories", "blvd_categories.blvd_id = blvd.id", 'category_id', $select::JOIN_INNER);
$select->join("categories", "blvd_categories.category_id = categories.id", array(), $select::JOIN_INNER);
$select->where(array("categories.main" => 1));
$select->order('category_id DESC, last_social_media_datetime DESC');
$mainSelect = new Select();
$mainSelect->from(new \Zend\Db\Sql\Expression( '?', array( $select )));
//$mainSelect->columns(array('*'));
//$mainSelect->from($select, array('*'))->group('category_id');
//$mainSelect->columns(array('name','category', 'last_social_media_datetime', '*' => new \Zend\Db\Sql\Expression( '?', array( $select ))))->group('category_id');
*/
}
示例8: fetchThumbArr
public function fetchThumbArr($dateYMon, $offset, $limit, $prevDateYMon, $nextDateYMon, $prevTotal)
{
$select = $this->sql->select();
$dateUt = mktime(0, 0, 0, date("m", strtotime($dateYMon)), 1, date("Y", strtotime($dateYMon)));
$select->where(array("unpublish=0", "date_inserted >= '" . date("Y-m-d 00:00:00", $dateUt) . "'"));
$year = date("Y", strtotime($dateYMon));
$month = date("m", strtotime($dateYMon));
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$dateUt = mktime(0, 0, 0, $month, $daysInMonth, $year);
$select->where(array("date_inserted <= '" . date("Y-m-d 23:59:59", $dateUt) . "'"));
$select->where(array('media_url IS NOT NULL'));
$select->order('id DESC');
$select->offset($offset);
$select->limit($limit);
$str = $select->getSqlString($this->dbAdapter->getPlatform());
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
if ($result->count() == 0) {
// if the date being requested is today's date and their are no results, return false so as to retry with previous month
return false;
}
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new GalleryModel());
$resultSet->initialize($result);
$resultSet->buffer();
$thumbArr = array();
$dateNowYM = date("Y-M");
$dateNextYM = 0;
$showNextPageLink = 0;
$showNextMonthLink = 0;
$key = 0;
foreach ($resultSet as $key => $obj) {
$thumbArr[$key]['thumb'] = $obj->getThumb();
$thumbArr[$key]['id'] = $obj->getId();
$dateYMon = date("Y-M", strtotime($obj->getDateInserted()));
$thumbArr[$key]['dateYMon'] = $dateYMon;
}
if ($limit == $resultSet->count()) {
// TODO readjust query to get from first of next month in where clause, and if first of next month is returned, showNextMonthLink instead
$showNextPageLink = 1;
} elseif ($nextDateYMon != 0) {
$showNextMonthLink = 1;
}
$key++;
$thumbArr[$key]['nav']['dateYMon'] = $dateYMon;
$thumbArr[$key]['nav']['prevDateYMon'] = $prevDateYMon;
$thumbArr[$key]['nav']['nextDateYMon'] = $nextDateYMon;
$thumbArr[$key]['nav']['showNextPageLink'] = $showNextPageLink;
$thumbArr[$key]['nav']['showNextMonthLink'] = $showNextMonthLink;
$thumbArr[$key]['nav']['page'] = $offset / $limit;
$maxPage = floor($prevTotal / $limit);
$thumbArr[$key]['nav']['prevMaxPage'] = $maxPage;
$thumbArr[$key]['nav']['limit'] = $limit;
return $thumbArr;
}