本文整理汇总了PHP中ResultSet::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::initialize方法的具体用法?PHP ResultSet::initialize怎么用?PHP ResultSet::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultSet
的用法示例。
在下文中一共展示了ResultSet::initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getuserRankByExp
public function getuserRankByExp($xp_point)
{
$dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($dbAdapter);
$select = $sql->select('player_rank_system');
$select->where->lessThan('min_exp', $xp_point);
$select->where->greaterThan('max_exp', $xp_point);
$statement = $sql->prepareStatementForSqlObject($select);
$rowset = $statement->execute();
$resultSet = new ResultSet();
$resultSet->initialize($rowset);
return $resultSet;
}
示例2: testExceptionIsThrownWhenGettingNonexistentAlbum
public function testExceptionIsThrownWhenGettingNonexistentAlbum()
{
$resultSet = new ResultSet();
$resultSet->setArrayObjectPrototype(new Album());
$resultSet->initialize(array());
$mockTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
$mockTableGateway->expects($this->once())->method('select')->with(array('id' => 123))->will($this->returnValue($resultSet));
$albumTable = new AlbumTable($mockTableGateway);
try {
$albumTable->getAlbum(123);
} catch (\Exception $e) {
$this->assertSame('Could not find row 123', $e->getMessage());
return;
}
$this->fail('Expected exception was not thrown');
}
示例3: findSegmentByTypeSegment
/**
* [findSegmentByTypeSegment description]
* @param ServiceLocator $sm
* @param int $typeSegment (ID du type de segment)
* @return array (Array de Segment)
*/
public function findSegmentByTypeSegment($sm, $typeSegment)
{
$idType = (int) $typeSegment;
$query = "SELECT id, intitule_segment \n FROM segment\n WHERE ref_type_segment = {$idType}";
$statement = $sm->get('Zend\\Db\\Adapter\\Adapter')->query($query);
$results = $statement->execute();
if ($results->isQueryResult()) {
$resultSet = new ResultSet();
$resultSet->initialize($results);
return $resultSet->toArray();
}
return array();
}
示例4: fetchAllPaginated
public function fetchAllPaginated($itemCountPerPage, $dateYM = false)
{
// create a new Select object for the table album
$select = new Select($this->table);
$select->where(array("unpublish=0"));
//$select->join("blvd", "blvd.id = gallery.blvd_id", SELECT::SQL_STAR, SELECT::JOIN_INNER);
$select->order('date_inserted DESC');
//echo $select->getSqlString($this->dbAdapter->getPlatform());
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new GalleryModel());
// create a new pagination adapter object
$paginatorAdapter = new DbSelect($select, $this->dbAdapter, $resultSetPrototype);
$paginator = new Paginator($paginatorAdapter);
if ($dateYM) {
$select = $this->sql->select();
$select->columns(array('num' => new \Zend\Db\Sql\Expression('COUNT(*)')));
$select->where(array("unpublish=0"));
$dateUt = mktime(0, 0, 0, date("m", strtotime($dateYM)) + 1, 1, date("Y", strtotime($dateYM)));
$select->where(array("date_inserted <= '" . date("Y-m-d 00:00:00", $dateUt) . "'"));
//echo "<br><br>".$select->getSqlString($this->dbAdapter->getPlatform());exit;
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
$rows = new ResultSet();
$arr = $rows->initialize($result)->toArray();
$num = $arr[0]['num'];
$totalItemCount = $paginator->getTotalItemCount();
$page = ceil(($totalItemCount - $num) / 36);
$paginator->setCurrentPageNumber($page);
}
$paginator->setItemCountPerPage($itemCountPerPage);
return $paginator;
}