本文整理汇总了PHP中Zend_Db_Adapter_Abstract::fetchPairs方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract::fetchPairs方法的具体用法?PHP Zend_Db_Adapter_Abstract::fetchPairs怎么用?PHP Zend_Db_Adapter_Abstract::fetchPairs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Abstract::fetchPairs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
{
if ($config) {
$errors = $this->validateConfiguration($config);
if ($errors) {
return $controller->responseError($errors);
}
if (isset($config['attachmentPath']) || isset($config['avatarPath'])) {
// already configured
return true;
}
$this->_bootstrap($config);
$settings = $this->_sourceDb->fetchPairs('
SELECT varname, value
FROM ' . $this->_prefix . 'setting
WHERE varname IN (\'attachpath\', \'attachfile\', \'avatarpath\', \'usefileavatar\')
');
if ($settings['attachfile'] && $settings['attachpath'] || $settings['usefileavatar'] && $settings['avatarpath']) {
return $controller->responseView('XenForo_ViewAdmin_Import_vBulletin_Config', 'import_vbulletin_config', array('config' => $config, 'attachmentPath' => $settings['attachfile'] ? $settings['attachpath'] : '', 'avatarPath' => $settings['usefileavatar'] ? $settings['avatarpath'] : '', 'retainKeys' => $config['retain_keys']));
}
return true;
} else {
$configPath = getcwd() . '/includes/config.php';
if (file_exists($configPath) && is_readable($configPath)) {
$config = array();
include $configPath;
$viewParams = array('input' => $config);
} else {
$viewParams = array('input' => array('MasterServer' => array('servername' => 'localhost', 'port' => 3306, 'username' => '', 'password' => ''), 'Database' => array('dbname' => '', 'tableprefix' => ''), 'Mysqli' => array('charset' => '')));
}
return $controller->responseView('XenForo_ViewAdmin_Import_vBulletin_Config', 'import_vbulletin_config', $viewParams);
}
}
示例2: configure
public function configure(XenForo_ControllerAdmin_Abstract $controller, array &$config)
{
if ($config) {
$errors = $this->validateConfiguration($config);
if ($errors) {
return $controller->responseError($errors);
}
if (isset($config['albumPicPath'])) {
return true;
}
$this->_bootstrap($config);
$settings = $this->_sourceDb->fetchPairs('
SELECT varname, value
FROM ' . $this->_prefix . 'setting
WHERE varname IN (\'attachfile\', \'attachpath\')
');
if (intval($settings['attachfile']) !== self::ATTACH_AS_DB) {
return $controller->responseView('XenGallery_ViewAdmin_Import_Config', 'xengallery_import_config_vbulletin', array('config' => $config, 'productName' => str_replace('XFMG: Import From ', '', self::getName()), 'albumPicPath' => $settings['attachpath'], 'attachType' => $settings['attachfile'], 'retainKeys' => $config['retain_keys']));
}
return true;
} else {
$configPath = getcwd() . '/includes/config.php';
if (file_exists($configPath) && is_readable($configPath)) {
$config = array();
include $configPath;
$viewParams = array('input' => $config);
} else {
$viewParams = array('input' => array('MasterServer' => array('servername' => 'localhost', 'port' => 3306, 'username' => '', 'password' => ''), 'Database' => array('dbname' => '', 'tableprefix' => ''), 'Mysqli' => array('charset' => '')), 'productName' => str_replace('XFMG: Import From ', '', self::getName()));
}
return $controller->responseView('XenForo_ViewAdmin_Import_vBulletin_Config', 'xengallery_import_config_vbulletin', $viewParams);
}
}
示例3: fetchAttrs
/**
* @param string $username
* @return array
*/
public function fetchAttrs($username)
{
$sql = "SELECT `key`, `value` FROM {$this->_prefix}attributes WHERE username = ?";
$attrs = $this->_db->fetchPairs($sql, $username);
if (empty($attrs)) {
return null;
}
return $attrs;
}
示例4: afterLoad
/**
* Override this function when you need to perform any actions when the data is loaded.
*
* Test for the availability of variables as these objects can be loaded data first after
* deserialization or registry variables first after normal instantiation.
*
* That is why this function called both at the end of afterRegistry() and after exchangeArray(),
* but NOT after unserialize().
*
* After this the object should be ready for serialization
*/
protected function afterLoad()
{
if ($this->_data && $this->db instanceof \Zend_Db_Adapter_Abstract && !$this->_locations) {
if ($this->_data['gaf_filter_text1']) {
$sqlActivites = "SELECT glo_id_location, glo_id_location\n FROM gems__locations\n WHERE glo_active = 1 AND glo_name LIKE '%s'\n ORDER BY glo_id_location";
$this->_locations = $this->db->fetchPairs(sprintf($sqlActivites, addslashes($this->_data['gaf_filter_text1'])));
} else {
$this->_locations = true;
}
}
}
示例5: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute()
{
$role = \Gems_Roles::getInstance();
$parents = $this->db->fetchPairs("SELECT grl_id_role, grl_parents FROM gems__roles");
// \MUtil_Echo::track($parents);
if ($parents) {
foreach ($parents as $id => $priv) {
$values['grl_parents'] = implode(',', $role->translateToRoleIds($priv));
$this->db->update('gems__roles', $values, $this->db->quoteInto('grl_id_role = ?', $id));
}
}
}
示例6: createModel
protected function createModel($detailed, $action)
{
$model = new \Gems_Model_JoinModel('chartconfig', 'gems__chart_config', 'gcc');
$empty = $this->loader->getUtil()->getTranslated()->getEmptyDropdownArray();
$model->set('gcc_tid', 'label', $this->_('Track'), 'multiOptions', $empty + $this->db->fetchPairs('SELECT gtr_id_track, gtr_track_name FROM gems__tracks ORDER BY gtr_track_name;'), 'onchange', 'this.form.submit();');
$model->set('gcc_rid', 'label', $this->_('Round'));
$model->set('gcc_sid', 'label', $this->_('Survey'), 'multiOptions', $empty + $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys ORDER BY gsu_survey_name;'));
$model->set('gcc_code', 'label', $this->_('Survey code'));
$model->set('gcc_description', 'label', $this->_('Description'));
$roundStatement = 'SELECT gro_id_round, concat_ws(" ", gro_id_order, gro_survey_name, gro_round_description) FROM gems__rounds ORDER BY gro_id_order;';
if ($detailed) {
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getParams();
if (array_key_exists('gcc_tid', $data) && !empty($data['gcc_tid'])) {
$trackId = (int) $data['gcc_tid'];
$roundStatement = 'SELECT gro_id_round, concat_ws(" ", gro_id_order, gro_survey_name, gro_round_description) FROM gems__rounds WHERE gro_id_track = ' . $trackId . ' ORDER BY gro_id_order;';
}
}
$default = '[
{
"question_code":[
"SCORE1",
"SCORE2"
],
"question_text":"DSM scores",
"grid":false,
"min":25,
"max":100,
"rulers":[
{
"value":60,
"class":"negative",
"label":"lower"
},
{
"value":69,
"class":"positive",
"label":"upper"
}
]
}
]';
$model->set('gcc_config', 'label', $this->_('Config'), 'elementClass', 'textArea', 'default', $default);
if ($action == 'show') {
$model->set('gcc_config', 'formatFunction', array($this, 'formatjsonpre'));
}
$model->setOnLoad('gcc_config', array($this, 'formatjson'));
}
$model->set('gcc_rid', 'multiOptions', $empty + $this->db->fetchPairs($roundStatement));
return $model;
}
示例7: afterRegistry
/**
* Called after the check that all required registry values
* have been set correctly has run.
*
* @return void
*/
public function afterRegistry()
{
parent::afterRegistry();
$this->orgTranslations = $this->db->fetchPairs('
SELECT gor_provider_id, gor_id_organization
FROM gems__organizations
WHERE gor_provider_id IS NOT NULL
ORDER BY gor_provider_id');
$this->orgTranslations = $this->orgTranslations + $this->db->fetchPairs('
SELECT gor_code, gor_id_organization
FROM gems__organizations
WHERE gor_code IS NOT NULL
ORDER BY gor_id_organization');
}
示例8: getUserData
/**
* Returns the data for a user object. It may be empty if the user is unknown.
*
* @param string $login_name
* @param int $organization
* @return array Of data to fill the user with.
*/
public function getUserData($login_name, $organization)
{
$orgs = null;
try {
$orgs = $this->db->fetchPairs("SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active = 1 ORDER BY gor_name");
natsort($orgs);
} catch (\Zend_Db_Exception $zde) {
}
if (!$orgs) {
// Table might not exist or be empty, so do something failsafe
$orgs = array($organization => 'create db first');
}
return array('user_id' => \Gems_User_UserLoader::SYSTEM_USER_ID, 'user_login' => $login_name, 'user_name' => $login_name, 'user_group' => 800, 'user_role' => $this->project->getConsoleRole(), 'user_style' => 'gems', 'user_base_org_id' => $organization, 'user_allowed_ip_ranges' => null, 'user_blockable' => false, '__allowedOrgs' => $orgs);
}
示例9: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($tableName = '', $idField = '', $passwordField = '', $methodField = '')
{
$passwords = $this->db->fetchPairs("SELECT {$idField}, {$passwordField} FROM {$tableName} WHERE {$passwordField} IS NOT NULL AND {$methodField} IS NULL");
if ($passwords) {
$values[$methodField] = 'default';
foreach ($passwords as $key => $password) {
$values[$passwordField] = $this->project->encrypt($password, $values[$methodField]);
$this->db->update($tableName, $values, "{$idField} = '{$key}'");
}
$this->getBatch()->addMessage(sprintf($this->_('%d passwords encrypted for table %s.'), count($passwords), $tableName));
} else {
$this->getBatch()->addMessage(sprintf($this->_('No passwords found in table %s.'), $tableName));
}
}
示例10: roundselectAction
/**
* Ajax return function for round selection
*/
public function roundselectAction()
{
\Zend_Layout::resetMvcInstance();
$trackId = $this->getRequest()->getParam('sourceValue');
$rounds = $this->db->fetchPairs($this->roundDescriptionQuery, $trackId);
echo json_encode($rounds);
}
示例11: loadData
/**
* Load the data when the cache is empty.
*
* @param mixed $id
* @return array The array of data values
*/
protected function loadData($id)
{
if (\Gems_User_UserLoader::SYSTEM_NO_ORG === $id) {
$data = false;
} else {
try {
$sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1";
$data = $this->db->fetchRow($sql, intval($id));
} catch (\Exception $e) {
$data = false;
}
}
if ($data) {
try {
$dbOrgId = $this->db->quote($id, \Zend_Db::INT_TYPE);
$sql = "SELECT gor_id_organization, gor_name\n FROM gems__organizations\n WHERE gor_active = 1 AND\n (\n gor_id_organization = {$dbOrgId} OR\n gor_accessible_by LIKE '%:{$dbOrgId}:%'\n )\n ORDER BY gor_name";
$data['can_access'] = $this->db->fetchPairs($sql);
natsort($data['can_access']);
} catch (\Exception $e) {
$data['can_access'] = array();
}
// \MUtil_Echo::track($sql, $data['can_access']);
if (array_key_exists('gor_url_base', $data) && ($baseUrls = explode(' ', $data['gor_url_base']))) {
$data['base_url'] = reset($baseUrls);
}
} else {
$data = $this->_noOrganization;
$data['gor_id_organization'] = $id;
}
return $data;
}
示例12: show
/**
* @param type $aParams
*/
public function show($aParams = null)
{
$aParams = $this->actionController->getRequest()->getParams();
$aDefaultOptions = array('' => 'Not selected');
$aControlsValues = array();
foreach ($this->_aParams['controls'] as $sKey => $aValue) {
$aControlsValues[$sKey] = array();
if (isset($aValue['values']) && !is_array($aValue['values'])) {
switch ($aValue['values']) {
case 'issue':
$aQuery = $this->_oDbAdapter->select()->from($aValue['values'], array('id', 'title'))->where('application = ?', $aParams['aid']);
$aControlsValues[$sKey] = $this->_oDbAdapter->fetchPairs($aQuery);
break;
default:
break;
}
}
if (!isset($this->_aParams['controls'][$sKey]['values']) || !is_array($aValue['values'])) {
is_array($aControlsValues[$sKey]) ? $aControlsValues[$sKey] = $aDefaultOptions + $aControlsValues[$sKey] : $aDefaultOptions;
} else {
$aControlsValues[$sKey] = $this->_aParams['controls'][$sKey]['values'];
}
}
$this->actionController->view->{$this->getName()} = array('controlsValues' => $aControlsValues);
parent::show();
}
示例13: getTabs
/**
* Function used to fill the tab bar
*
* @return array tabId => label
*/
protected function getTabs()
{
$user = $this->loader->getCurrentUser();
$sql = "SELECT gr2o_id_organization, gr2o_patient_nr FROM gems__respondent2org WHERE gr2o_id_user = ?";
$this->defaultTab = $user->getCurrentOrganizationId();
$this->currentTab = $this->request->getParam(\MUtil_Model::REQUEST_ID2);
$allowedOrgs = $user->getRespondentOrganizations();
$existingOrgs = $this->db->fetchPairs($sql, $this->respondent->getId());
$tabs = array();
foreach ($allowedOrgs as $orgId => $name) {
if (isset($existingOrgs[$orgId])) {
$tabs[$orgId] = $name;
$this->hrefs[$orgId] = array(\MUtil_Model::REQUEST_ID1 => $existingOrgs[$orgId], \MUtil_Model::REQUEST_ID2 => $orgId, 'RouteReset' => true);
}
}
return $tabs;
}
示例14: _getUserGroupPermsForUserGroup
protected function _getUserGroupPermsForUserGroup($userGroupId)
{
return $this->_sourceDb->fetchPairs('
SELECT permission, add_deny
FROM ' . $this->_prefix . 'permissions
WHERE id_group = ?
', $userGroupId);
}
示例15: getCategoriesListByModule
/**
* Возвращает плоский список разделов, привязанных к определенному модулю
*
* @param int $moduleid Id модуля
* @return array
*/
public function getCategoriesListByModule($moduleid = null)
{
$select = $this->_db->select()->from('pw_categories', array('categoryid', 'categoryname'))->order('cleft');
if (!is_null($moduleid)) {
$select->where('moduleid=?', $moduleid);
}
return $this->_db->fetchPairs($select);
}