本文整理匯總了PHP中dibi::fetchPairs方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::fetchPairs方法的具體用法?PHP dibi::fetchPairs怎麽用?PHP dibi::fetchPairs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::fetchPairs方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createComponentAddEdit
protected function createComponentAddEdit($name)
{
$form = new AppForm($this, $name);
$access = array(1 => 'Allow', 0 => 'Deny');
// roles
$mroles = new RolesModel();
$roles = $mroles->getTreeValues();
// resources
$resources[0] = '- All resources -';
$mresources = new ResourcesModel();
$rows = $mresources->getTreeValues();
foreach ($rows as $key => $row) {
// function array_merge does't work correctly with integer indexes
// manual array merge
$resources[$key] = $row;
}
// privileges
$privileges[0] = '- All privileges -';
$rows = dibi::fetchAll('SELECT id, name FROM %n ORDER BY name;', TABLE_PRIVILEGES);
foreach ($rows as $row) {
// function array_merge does't work correctly with integer indexes
// manual array merge
$privileges[$row->id] = $row->name;
}
// assertions
$assertions = array('Choose') + dibi::fetchPairs('SELECT id, class FROM %n ORDER BY class', TABLE_ASSERTIONS);
//$renderer = $form->getRenderer();
//$renderer->wrappers['label']['suffix'] = ':';
//$form->addGroup('Add');
$form->addMultiSelect('role_id', 'Role', $roles, 15)->addRule(Form::FILLED, 'You have to fill roles.');
$form->addMultiSelect('resource_id', 'Resources', $resources, 15)->addRule(Form::FILLED, 'You have to fill resources.');
$form->addMultiSelect('privilege_id', 'Privileges', $privileges, 15)->addRule(Form::FILLED, 'You have to fill privileges.');
$form->addSelect('assertion_id', 'Assertion', $assertions);
//$form->addSelect('access', 'Access', $access)
$form->addRadioList('access', 'Access', $access)->addRule(Form::FILLED, 'You have to fill access.');
$form->addSubmit('assign', 'Assign');
$form->onSubmit[] = array($this, 'addEditOnFormSubmitted');
}
示例2: load
public function load()
{
$this->vars = dibi::fetchPairs("SELECT name, value FROM configs");
}
示例3: _filterByContext
/**
* determine signatures with the same context
* currently we only check if the class we detected matches the signature
*
* @param array $candidates Array of DibiRows
* @return array
*/
protected function _filterByContext($candidates)
{
if (false === array_key_exists('class', $this->_context) && 0 < strlen($this->_context['class']) && Method::TYPE_MIXED !== $this->_context['class'] && 0 < count($candidates)) {
$classIds = array();
$query = 'SELECT name, id FROM [classes] WHERE id IN (%s) AND name=%s';
foreach ($candidates as $key => $candidate) {
if ($candidate->class_id) {
$classIds[$key] = $candidate->class_id;
}
}
try {
$result = dibi::fetchPairs($query, $classIds, $this->_context['class']);
} catch (\DibiDriverException $e) {
dibi::test($query, $classIds, $this->_context['class']);
throw $e;
}
$contextMatchingCandidates = $candidates;
foreach ($candidates as $key => $candidate) {
if (false == in_array($candidate->class_id, $classIds)) {
unset($contextMatchingCandidates[$key]);
}
}
return count($contextMatchingCandidates) ? $contextMatchingCandidates : $candidates;
}
return $candidates;
}