本文整理汇总了PHP中Zend_Db_Table::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::fetchAll方法的具体用法?PHP Zend_Db_Table::fetchAll怎么用?PHP Zend_Db_Table::fetchAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table
的用法示例。
在下文中一共展示了Zend_Db_Table::fetchAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenuTree
/**
* Получаем дерево разделов определённого меню
*
* @param int $menuId
* @return array
*/
public function getMenuTree($menuId)
{
$menu = $this->getMenu($menuId);
if (!sizeof($menu)) {
return array();
}
$sections = $this->_modelItems->fetchAll($this->_modelItems->select()->where('menu_id = ?', $menu->menu_id)->order('sort', 'item_id'));
if ($menu->type == 'router') {
$routerTree = Modules_Router_Model_Router::getInstance()->getItem($menu->parent_route_id);
$_makeTreeFromRouter = function ($routerTree, $sections, $parentDisable) use(&$_makeTreeFromRouter) {
$return = array();
foreach ($routerTree as $i => $row) {
if (1 == $row['disable']) {
continue;
}
$return[$i] = $row;
$return[$i]['type'] = 'from_router';
$return[$i]['item_id'] = $row['route_id'];
$return[$i]['parent_id'] = $row['parent_route_id'];
$return[$i]['disable'] = $parentDisable;
unset($return[$i]['route_id'], $return[$i]['parent_route_id'], $return[$i]['childs']);
if (sizeof($sections)) {
foreach ($sections as $item) {
if ($item->route_id == $row['route_id']) {
$return[$i]['disable'] = $item->disable || $parentDisable;
$return[$i]['name'] = $item->name ? $item->name : $row['name'];
}
}
}
$return[$i]['childs'] = $_makeTreeFromRouter($row['childs'], $sections, $return[$i]['disable']);
}
return $return;
};
$sections = $_makeTreeFromRouter($routerTree['childs'], $sections, false);
} else {
$_makeUrl = function ($sections) use(&$_makeUrl) {
$return = array();
foreach ($sections as $i => $item) {
$return[$i] = $item;
if ($item['external_link']) {
$return[$i]['url'] = $item['external_link'];
} else {
$return[$i] += Modules_Router_Model_Router::getInstance()->getItem($item['route_id']);
}
$return[$i]['childs'] = $_makeUrl($item['childs']);
}
return $return;
};
$sections = System_Functions::toForest($sections->toArray(), 'item_id', 'parent_id');
$sections = $_makeUrl($sections);
}
$this->_setCurrents($sections);
return $sections;
}
示例2: getTrustedSites
/**
* Returns array of all trusted/untrusted sites for given user identified
* by $id
*
* @param string $id user identity URL
* @return array
*/
public function getTrustedSites($id)
{
$select = $this->_sitesTable->select()->where('openid = ?', $id);
$rows = $this->_sitesTable->fetchAll($select);
$array = $rows->toArray();
$array['trusted'] = unserialize($array['trusted']);
return $array;
}
示例3: getReceivers
public function getReceivers($pairs = false)
{
$triggersTable = new Zend_Db_Table('email_triggers_recipient');
if ($pairs) {
$select = $triggersTable->select();
return $triggersTable->getAdapter()->fetchPairs($select);
} else {
return $triggersTable->fetchAll()->toArray();
}
}
示例4: _init
private function _init()
{
global $logger;
$oTable = new Zend_Db_Table('path');
foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
$this->_path[] = $xt['name'];
}
$oTable = new Zend_Db_Table('container');
$t = array();
foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
$t[] = $xt['name'];
}
$this->_extensions = implode(',', $t);
$logger->log('Valid extensions are : ' . $this->_extensions, Zend_Log::DEBUG);
}
示例5: getTable
function getTable($name)
{
if (!($result = $this->_cache->load($this->_options[$name]['table']))) {
$table = new Zend_Db_Table($this->_options[$name]['table']);
if ($name == 'privilege') {
$sql = new Zend_Db_Select($table->getDefaultAdapter());
$sql->from(array('acl' => $this->_options['privilege']['table']), array('acl.ID_PERFIL'))->join(array('r' => $this->_options['resource']['table']), 'acl.ID_MENU=r.ID_MENU', array('r.URL_MENU', 'acl.PERMISO'));
$result = $table->getAdapter()->fetchAll($sql);
} else {
$result = $table->fetchAll();
}
$this->_cache->save($result, $this->_options[$name]['table']);
}
return $result;
}
示例6: load
/**
* retourne tous les parametres
*
* @return Settings
*/
public function load()
{
global $logger;
$this->_init();
foreach ($this->_tables as $holder => $table) {
$oTable = new Zend_Db_Table($table);
$xt = array();
foreach ($oTable->fetchAll($oTable->select()->order('id ASC'))->toArray() as $o) {
$xsetting = new Setting();
$xsetting->name = $o['name'];
$xsetting->id = $o['id'];
$xt[] = $xsetting;
}
$t[$holder] = $xt;
}
$s = new Settings($this->_description, $t[0], $t[1], $t[2], $t[3], $t[4], $t[5], $t[6], $t[7], $t[8]);
return $s;
}
示例7: fetchAll
public function fetchAll($where = null, $order = null, $count = null, $offset = null)
{
$res = parent::fetchAll($where, $order, $count, $offset)->toArray();
// do Bacula ACLs
return $this->bacula_acl->doBaculaAcl($res, 'name', 'client');
}
示例8: getYnModulesOnYourSite
public function getYnModulesOnYourSite($modules,$yours)
{
$lst_modules = array();
$db = Engine_Api::_()->getDbtable('license', 'younetcore')->getAdapter();
if( $db ) {
try {
$table = new Zend_Db_Table(array(
'adapter' => $db,
'name' => 'engine4_core_modules',
));
foreach( $table->fetchAll() as $row ) {
$lst_modules[$row->name] = $row->toArray();
}
} catch( Exception $e ) {
}
}
$modules_yn = array();
if(count($lst_modules)>0)
{
foreach($lst_modules as $key =>$m)
{
$t = false;
if(count($yours) >0)
{
if(array_key_exists($m['name'],$yours))
{
$t = true;
}
}
if(array_key_exists($m['name'],$modules) && $t == false && $m['name']!="younet-core")
{
if($this->checkMainifest($m['name']) == 2)
{
$modules_yn[$m['name']] = array(
'title' => $m['title'],
'name' => $m['name'],
'type' => 'module',
'current_version' => $m['version'],
'lasted_version' => $m['version'],
'is_active' =>$m['enabled'],
//'sort_description' =>$m['sort_description'],
);
$db->beginTransaction();
try {
$table = Engine_Api::_()->getDbtable('License', 'YounetCore');
$st = $table->createRow();
$st->setFromArray($modules_yn[$m['name']]);
$st->save();
$db->commit();
} catch (Exception $e) {
$db->rollback();
//throw $e;
}
}
else
{
$db->beginTransaction();
try {
$table = Engine_Api::_()->getDbtable('License', 'YounetCore');
$where = $table->getAdapter()->quoteInto('name = ?', $m['name']);
$table->delete($where);
$db->commit();
} catch (Exception $e) {
$db->rollback();
//throw $e;
}
}
}
}
}
return $modules_yn;
}
示例9: fetchUserFriends
public function fetchUserFriends($id)
{
$id = (int) $id;
$table = new Zend_Db_Table('friends');
$select = $table->select()->setIntegrityCheck(false);
$select->from(array('f' => 'friends'), array('f.id_friend'));
$select->where('f.id_user = ?', $id);
$select->joinInner(array('u' => 'users'), 'f.id_friend = u.id', array('u.username'));
return $table->fetchAll($select)->toArray();
}
示例10: fetchAll
public function fetchAll($where = null, $order = null, $count = null, $offset = null)
{
$result = parent::fetchAll($where, $order, $count, $offset);
return $result;
}
示例11: _updateContractsFields
/**
* adds "start_date", "end_date" to contract and removes "status", "cleared", "cleared_in"
*/
protected function _updateContractsFields()
{
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
$groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
if (count($groupMembers) > 0) {
$user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
Tinebase_Core::set(Tinebase_Core::USER, $user);
// cleared, cleared_in, status gets deleted, if the update is not called on cli
$controller = Sales_Controller_Contract::getInstance();
$table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
$count = 50;
$offset = 0;
$more = true;
$updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
$appId = Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId();
$pref = Tinebase_Core::getPreference('Tinebase');
Tinebase_Core::setupUserLocale($pref->locale);
$t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
$config = Sales_Config::getInstance()->get('contractStatus');
foreach ($config['records'] as $cfg) {
$statusConfig[$cfg['id']] = $cfg['value'];
}
$config = Sales_Config::getInstance()->get('contractCleared');
foreach ($config['records'] as $cfg) {
$clearedConfig[$cfg['id']] = $cfg['value'];
}
while ($more) {
$results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
foreach ($results as $row) {
if ($row['status'] == 'CLOSED') {
$setEndDate[$row['id']] = $row['last_modified_time'];
}
$desc = $row['description'];
$desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
$contents = FALSE;
if (!empty($row['status'])) {
$desc .= $t->_('Status') . ': ';
$desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared'])) {
$desc .= $t->_('Cleared') . ': ';
$desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared_in'])) {
$desc .= $t->_('Cleared In') . ': ';
$desc .= $row['cleared_in'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if ($contents) {
$updateDescription[$row['id']] = $desc . PHP_EOL;
}
}
if (count($updateDescription) > 50) {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
$updateDescription = array();
}
if (count($results) < $count) {
$more = FALSE;
} else {
$offset = $offset + $count;
}
}
try {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
} catch (Tinebase_Exception_AccessDenied $tead) {
// could not update contracts ...
Tinebase_Exception::log($tead);
}
}
// remove deprecated sales contract fields
foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
try {
$this->_backend->dropCol('sales_contracts', $colToDrop);
} catch (Zend_Db_Statement_Exception $zdse) {
Tinebase_Exception::log($zdse);
}
}
// add new sales contract fields
$fields = array('<field>
<name>start_date</name>
<type>datetime</type>
</field>', '
<field>
<name>end_date</name>
<type>datetime</type>
</field>');
//.........这里部分代码省略.........
示例12: fetchAllMaster
public function fetchAllMaster($where = null, $order = null, $count = null, $offset = null)
{
$this->_db = CrFramework_Db_Control::getMasterAdapter();
$this->setDefaultAdapter($this->_db);
logStd(get_class($this) . '->fetchAll()', 'Read from MASTER');
$rowset = parent::fetchAll($where, $order, $count, $offset);
return $rowset;
}
示例13: indexAction
public function indexAction()
{
$contact = new Zend_Db_Table('contacts');
$query = $contact->select()->order('name');
$this->view->contacts = $contact->fetchAll($query);
}
示例14: getAdListAllHome
public function getAdListAllHome($ad_type)
{
$table = new Zend_Db_Table('ads');
$select = $table->select()->setIntegrityCheck(false);
$select->from(array('a' => 'ads'), array('a.*'));
$select->joinLeft(array('c' => 'commentsAdCount'), 'a.id = c.id_comment', array('c.count as comments_count'));
$select->joinLeft(array('r' => 'readedAdCount'), 'a.id = r.id_ad', array('r.counter as readings_count'));
$select->join(array('u' => 'users'), 'a.user_owner = u.id', array('u.username'));
//show only if user is active and not locked
$select->where('u.active = ?', 1);
$select->where('u.locked = ?', 0);
$select->where('a.type = ?', $ad_type);
$select->where('a.status = ?', 'available');
$select->order('a.date_created DESC');
$select->limit(20);
$result = $table->fetchAll($select)->toArray();
return $result;
}
示例15: getMessagesFromThread
/**
* get messages in a thread
*
* @param thread_id
* @return array of messages
*/
public function getMessagesFromThread($id)
{
if (!$id) {
return null;
}
$messages_table = new Zend_Db_Table('messages');
$select = $messages_table->select()->setIntegrityCheck(false)->from('messages', array('user_from', 'user_to', 'date_created', 'body'))->where('thread_id = ?', $id)->join(array('u' => 'users'), 'user_from = u.id', array('username_from' => 'u.username'))->order('date_created');
$result = $messages_table->fetchAll($select)->toArray();
return $result;
}