本文整理汇总了PHP中Zend\Db\ResultSet\ResultSet::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::toArray方法的具体用法?PHP ResultSet::toArray怎么用?PHP ResultSet::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\ResultSet\ResultSet
的用法示例。
在下文中一共展示了ResultSet::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToArrayCreatesArrayOfArraysRepresentingRows
public function testToArrayCreatesArrayOfArraysRepresentingRows()
{
$count = rand(3, 75);
$dataSource = $this->getArrayDataSource($count);
$this->resultSet->initialize($dataSource);
$test = $this->resultSet->toArray();
$this->assertEquals($dataSource->getArrayCopy(), $test, var_export($test, 1));
}
示例2: getUnusedCategories
/**
* Get unused categories
*
* @param integer $limit
* @return array
*/
public function getUnusedCategories($limit)
{
$select = $this->select();
$select->from('slideshow_category')->columns(['id', 'name'])->limit($limit)->where->and->isNull('language');
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
return $resultSet->toArray();
}
示例3: getEmptyTransactions
/**
* Get all empty transactions
*
* @param integer $limit
* @return array
*/
public function getEmptyTransactions($limit)
{
$predicate = new Predicate();
$select = $this->select();
$select->from(['a' => 'payment_transaction_list'])->columns(['id', 'slug'])->join(['b' => 'payment_transaction_item'], 'a.id = b.transaction_id', [], 'left')->where([$predicate->isNull('b.transaction_id')])->group('a.id')->limit($limit);
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
return $resultSet->toArray();
}
示例4: getExpiredMembershipsConnections
/**
* Get all expired memberships connections
*
* @param integer $limit
* @return array
*/
public function getExpiredMembershipsConnections($limit)
{
$predicate = new Predicate();
$select = $this->select();
$select->from(['a' => 'membership_level_connection'])->columns(['id', 'user_id'])->join(['b' => 'membership_level'], 'a.membership_id = b.id', ['role_id'], 'left')->join(['c' => 'user_list'], 'a.user_id = c.user_id', ['nick_name', 'email', 'language'])->join(['d' => 'acl_role'], 'd.id = b.role_id', ['role_name' => 'name'], 'left')->limit($limit)->where(['a.active' => self::MEMBERSHIP_LEVEL_CONNECTION_ACTIVE, $predicate->lessThanOrEqualTo('a.expire_date', time())])->where->or->equalTo('a.active', self::MEMBERSHIP_LEVEL_CONNECTION_ACTIVE)->and->isNull('a.membership_id');
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
return $resultSet->toArray();
}
示例5: sequence
protected function sequence($sequence)
{
return $this->generateCode(function () use($sequence) {
$query = $this->getTableGateway()->adapter->getDriver()->createStatement("SELECT currval('{$sequence}') AS retorno")->execute();
$resultSet = new ResultSet();
$resultSet->initialize($query);
$retorno = $resultSet->toArray();
return $retorno[0]['retorno'];
});
}
示例6: toArray
public function toArray()
{
if ($this->dataSource instanceof Result) {
return $this->dataSource->getResource()->fetchAll(\PDO::FETCH_ASSOC);
}
// todo: реализовать подгрузку mysqli значений
// if ($this->dataSource instanceof \Zend\Db\Adapter\Driver\Mysqli\Result) {
// $this->dataSource->getResource()
// }
return parent::toArray();
}
示例7: select
public function select($where)
{
$sql = $this->tableGateway->getSql();
$select = $this->tableGateway->getSql()->select();
$select->where($where);
$statement = $sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
$resultSet = new ResultSet();
$resultSet->initialize($results);
return $resultSet->toArray();
}
示例8: getIntitulesConditionReglement
public function getIntitulesConditionReglement($sm)
{
$query = "SELECT intitule_condition_reglement\n FROM condition_reglement";
$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();
}
示例9: getEligibleDispoRecipient
public function getEligibleDispoRecipient()
{
$sql = $this->getObjDbSql();
$select = $sql->select();
$select->columns(array('u_kode', 'u_nama', 'u_kode_fungsional', 'u_gelar_diplomatik', 'u_urutan'));
$select->from($this->table);
$select->where(array('u_status=1', 'u_urutan > 0'));
$select->order('u_urutan ASC');
$statement = $sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
$resultSet = new ResultSet();
$resultSet->initialize($result);
return $resultSet->toArray();
}
示例10: getTotal
/**
* Определить число записей.
* @param $adapter (адаптер к базе или таблица)
* @param string $sql (если адаптер, то текст запроса, иначе не использовать)
* @return integer
*/
private function getTotal($adapter, $sql = null)
{
if ($adapter instanceof TableGateway) {
$table = $adapter;
$select = $table->getSql()->select()->columns(array("count" => new Expression("count(*)")));
$totalSet = $table->selectWith($select);
} else {
$statement = $adapter->createStatement($sql);
$totalSet = new ResultSet();
$totalSet->initialize($statement->execute());
}
$total = $totalSet->toArray();
$total = $total[0]["count"];
return (int) $total;
}
示例11: getAll
/**
* Get all countries.
*
* @param string|null $continentCode The continent code
* @return array
*/
public function getAll($continentCode = null)
{
$sql = new Sql($this->adapter);
$select = $sql->select('iso_3166_1');
if (null !== $continentCode) {
$select->where(array('continent_alpha_2' => $continentCode));
}
$statement = $sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
if ($result instanceof ResultInterface && $result->isQueryResult()) {
$resultSet = new ResultSet();
$resultSet->initialize($result);
return $resultSet->toArray();
}
return array();
}
示例12: getClasses
/**
* Get all classes
*
* @return array
*/
public function getClasses()
{
// generate cache name
$cacheName = CacheUtility::getCacheName(self::CACHE_XMLRPC_CLASSES);
// check data in cache
if (null === ($classes = $this->staticCacheInstance->getItem($cacheName))) {
$select = $this->select();
$select->from(['a' => 'xmlrpc_class'])->columns(['namespace', 'path', 'module'])->join(['b' => 'application_module'], new Expression('a.module = b.id and b.status = ?', [self::MODULE_STATUS_ACTIVE]), []);
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
$classes = $resultSet->toArray();
// save data in cache
$this->staticCacheInstance->setItem($cacheName, $classes);
$this->staticCacheInstance->setTags($cacheName, [self::CACHE_XMLRPC_DATA_TAG]);
}
return $classes;
}
示例13: getDefaultActiveLayouts
/**
* Get default active layouts
*
* @return array
*/
public function getDefaultActiveLayouts()
{
// generate cache name
$cacheName = CacheUtility::getCacheName(self::CACHE_LAYOUTS_ACTIVE);
// check data in cache
if (null === ($layouts = $this->staticCacheInstance->getItem($cacheName))) {
$defaultActiveCustomLayout = (int) SettingService::getSetting('layout_active');
$select = $this->select();
$select->from('layout_list')->columns(['name'])->order('type')->where(['type' => self::LAYOUT_TYPE_SYSTEM]);
if ($defaultActiveCustomLayout) {
$select->where->or->equalTo('id', $defaultActiveCustomLayout)->and->equalTo('type', self::LAYOUT_TYPE_CUSTOM);
}
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
$layouts = $resultSet->toArray();
// save data in cache
$this->staticCacheInstance->setItem($cacheName, $layouts);
$this->staticCacheInstance->setTags($cacheName, [self::CACHE_LAYOUTS_DATA_TAG]);
}
return $layouts;
}
示例14: getFooterMenu
/**
* Get footer menu
*
* @param string $language
* @return array
*/
public function getFooterMenu($language)
{
$cacheName = CacheUtility::getCacheName(self::CACHE_FOOTER_MENU . $language);
// check data in a cache
if (null === ($footerMenu = $this->staticCacheInstance->getItem($cacheName))) {
// get the footer menu
$select = $this->select();
$select->from(['a' => 'page_structure'])->columns(['slug', 'title', 'type'])->join(['b' => 'page_system'], 'b.id = a.system_page', ['system_title' => 'title'], 'left')->where(['a.footer_menu' => PageNestedSet::PAGE_IN_FOOTER_MENU, 'a.language' => $language])->order('a.footer_menu_order');
$statement = $this->prepareStatementForSqlObject($select);
$resultSet = new ResultSet();
$resultSet->initialize($statement->execute());
$footerMenu = $resultSet->toArray();
// save data in cache
$this->staticCacheInstance->setItem($cacheName, $footerMenu);
$this->staticCacheInstance->setTags($cacheName, [self::CACHE_PAGES_DATA_TAG]);
}
return $footerMenu;
}
示例15: getProduitsFinisId
public function getProduitsFinisId($sm)
{
$id = $this->getId();
if ($id) {
$query = "SELECT ref_produit_fini\n FROM client_a_produit_fini\n WHERE ref_client = {$id}";
$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();
}