本文整理汇总了PHP中Database::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::fetchAll方法的具体用法?PHP Database::fetchAll怎么用?PHP Database::fetchAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::fetchAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
function findById($id)
{
$sql = "SELECT * FROM " . $this->tableName() . ' WHERE id= :id';
$res = $this->db->query($sql, array('id' => $id));
$data = $this->db->fetchAll($res, Database::FETCH_CLASS, $this->entityName());
return $data;
}
示例2: index
public function index()
{
$this->document->setTitle(Language::getVar('SUMO_ADMIN_THEMES_SETTINGS'));
$this->document->addBreadcrumbs(array('text' => Language::getVar('SUMO_ADMIN_SETTINGS_DASHBOARD'), 'href' => $this->url->link('settings/dashboard', '', 'SSL')));
$this->document->addBreadcrumbs(array('text' => Language::getVar('SUMO_ADMIN_THEMES_SETTINGS')));
$templates = glob(DIR_HOME . 'catalog/view/theme/*');
foreach ($templates as $dir) {
$tmp = explode('/', $dir);
$name = end($tmp);
if (file_exists($dir . '/information.php')) {
include $dir . '/information.php';
$template[$name]['edit'] = $this->url->link('settings/themes/builder', 'token=' . $this->session->data['token'] . '&theme=' . $name, 'SSL');
} else {
Logger::warning('Template ' . $name . ' does not have information.php');
$template[$name] = array('error' => true);
}
$template[$name]['active'] = array();
$stores = Database::fetchAll("SELECT store_id FROM PREFIX_settings_stores WHERE setting_name = 'template' AND setting_value = :tmpl", array('tmpl' => $name));
foreach ($stores as $check) {
$store = Database::query("SELECT setting_value AS name FROM PREFIX_settings_stores WHERE store_id = :id AND setting_name = 'title'", array('id' => $check['store_id']))->fetch();
if (is_array($store)) {
$template[$name]['active'][] = $store['name'];
}
}
$this->data['themes'][$name] = $template[$name];
}
$this->template = 'settings/themes/list.tpl';
$this->children = array('common/header', 'common/footer');
$this->response->setOutput($this->render());
}
示例3: getTranslationsByTranslation
public function getTranslationsByTranslation($letter = '', $language_id = 0)
{
if (!$language_id) {
return false;
}
if (strlen($letter) == 1) {
return Database::fetchAll("\n SELECT t.id, t.key_id, t.value, tk.name\n FROM PREFIX_translations AS t\n LEFT JOIN PREFIX_translations_keys AS tk\n ON tk.id = t.key_id\n WHERE t.language_id = :lid\n AND LOWER(t.value) LIKE :search\n ORDER BY t.value ASC", array('lid' => $language_id, 'search' => '' . $letter . '%'));
} else {
if ($letter == 'empty') {
$ignore = '';
$ignoreList = Database::fetchAll("\n SELECT key_id AS id\n FROM PREFIX_translations\n WHERE language_id = :lang\n ", array('lang' => $language_id));
foreach ($ignoreList as $list) {
if (empty($ignore)) {
$ignore = $list['id'];
} else {
$ignore .= ',' . $list['id'];
}
}
if (!empty($ignore)) {
$ignore = 'WHERE tk.id NOT IN(' . $ignore . ')';
}
return Database::fetchAll("\n SELECT id, name, (SELECT value FROM PREFIX_translations WHERE key_id = tk.id AND language_id = :default) AS default_value\n FROM PREFIX_translations_keys AS tk\n " . $ignore . "\n ORDER BY default_value ASC", array('default' => $this->config->get('config_language_id')));
} else {
return Database::fetchAll("\n SELECT t.id, t.key_id, t.value, tk.name\n FROM PREFIX_translations AS t\n LEFT JOIN PREFIX_translations_keys AS tk\n ON tk.id = t.key_id\n WHERE t.language_id = :lid\n AND (\n t.value LIKE '<%'\n OR t.value LIKE '\\%%'\n OR t.value LIKE '(%'\n OR t.value LIKE '^%'\n OR t.value LIKE '!%'\n OR t.value LIKE '\$%'\n OR t.value LIKE '*%'\n OR t.value LIKE ''\n )\n ORDER BY t.value ASC", array('lid' => $language_id));
}
}
}
示例4: getStockStatuses
public function getStockStatuses($data = array())
{
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "stock_status WHERE language_id = '" . (int) $this->config->get('config_language_id') . "'";
$sql .= " ORDER BY name";
if (isset($data['order']) && $data['order'] == 'DESC') {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
} else {
return Database::fetchAll("SELECT stock_status_id, name\n FROM PREFIX_stock_status\n WHERE language_id = :lang\n ORDER BY name", array('lang' => $this->config->get('language_id')));
}
}
示例5: get
static function get($params = array())
{
$query = 'SELECT * FROM bad_player';
if (isset($params['order_by'])) {
$query .= ' ORDER BY ' . $params['order_by'];
}
return Database::fetchAll($query);
}
示例6: getExtensions
public function getExtensions($type)
{
$cache = Cache::find('extensions.' . $this->config->get('config_store_id'), $type);
if (!is_array($cache)) {
$cache = Database::fetchAll("SELECT * FROM PREFIX_extension WHERE `type` = :type", array('type' => $type));
Cache::set('extensions.' . $this->config->get('config_store_id'), $type, $cache);
}
return $cache;
}
示例7: getStores
public function getStores($data = array())
{
$store_data = Cache::find('store');
if (!$store_data || !is_array($store_data) || empty($store_data)) {
$store_data = Database::fetchAll("SELECT * FROM PREFIX_store ORDER BY url");
Cache::set('store', $store_data);
}
return $store_data;
}
示例8: getSettings
public function getSettings($refresh = false)
{
if (is_array($this->settings) && count($this->settings) && !$refresh) {
return $this->settings;
}
foreach (Database::fetchAll("SELECT setting_name, setting_value, is_json FROM PREFIX_settings") as $list) {
$this->settings[$list['setting_name']] = $list['is_json'] ? json_decode($list['setting_value'], true) : $list['setting_value'];
}
return $this->settings;
}
示例9: getSettings
public function getSettings($store_id, $refresh = false)
{
if (is_array($this->settings) && count($this->settings) && !$refresh) {
return $this->settings;
}
$this->settings[$store_id] = $this->getStore($store_id);
foreach (Database::fetchAll("SELECT setting_name, setting_value, is_json FROM PREFIX_settings_stores WHERE store_id = :id", array('id' => $store_id)) as $list) {
$this->settings[$store_id][$list['setting_name']] = $list['is_json'] ? json_decode($list['setting_value'], true) : $list['setting_value'];
}
return $this->settings[$store_id];
}
示例10: testFetchAll
/**
* @covers DataBase::fetchAll
*/
public function testFetchAll()
{
$result = $this->db->fetchAll("SELECT * FROM test");
$this->assertInternalType('array', $result, LoggerApp::getLastError());
$this->assertEquals(3, count($result));
$this->assertEquals(3, $this->db->rowCount());
for ($i = 1; $i <= 3; $i++) {
$this->assertEquals('value ' . $i, $result[$i - 1]['name']);
}
$r1 = $this->db->fetchAll("SELECT * FROM test WHERE id > ? ORDER BY id", 1);
$this->assertFalse(LoggerApp::hasError(), LoggerApp::getLastError());
$this->assertEquals(2, count($r1));
$this->assertEquals(2, $this->db->rowCount());
for ($i = 2; $i <= 3; $i++) {
$this->assertEquals('value ' . $i, $r1[$i - 2]['name']);
}
$r2 = $this->db->fetchAll("SELECT * FROM test WHERE id < ?", array(0));
$this->assertFalse(LoggerApp::hasError(), LoggerApp::getLastError());
$this->assertEquals(0, $this->db->rowCount());
$this->assertEmpty($r2, 'Retorno deveria ser vazio');
}
示例11: create_general_list
public function create_general_list()
{
$db = new Database();
$db->query("SELECT * FROM movie ORDER BY RAND()");
$values = $db->fetchAll();
$list = array();
for ($i = 0; $i < count($values); $i++) {
array_push($list, $values[$i]['id']);
}
$_SESSION["movie_list"] = $list;
$db = null;
$this->create_url_from_list();
}
示例12: __construct
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$weights = Cache::find('weights.' . $this->config->get('config_language_id'));
if (!is_array($weights)) {
$weights = Database::fetchAll("SELECT * FROM PREFIX_weight_class AS wc LEFT JOIN PREFIX_weight_class_description AS wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = :lang", array('lang' => $this->config->get('config_language_id')));
Cache::set('weights.' . $this->config->get('config_language_id'), $weights);
}
foreach ($weights as $result) {
$this->weights[$result['weight_class_id']] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
示例13: __construct
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$lengths = Cache::find('lengths.' . $this->config->get('config_language_id'));
if (!is_array($lengths)) {
$lengths = Database::fetchAll("SELECT * FROM PREFIX_length_class AS lc LEFT JOIN PREFIX_length_class_description AS lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = :lang", array('lang' => $this->config->get('config_language_id')));
Cache::set('lengths.' . $this->config->get('config_language_id'), $lengths);
}
foreach ($lengths as $result) {
$this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
示例14: getTemplate
public static function getTemplate($idOrKey, $language_id = null)
{
if ($language_id == null || !$language_id) {
$language_id = self::$config->get('language_id');
}
if (is_string($idOrKey) && !is_numeric($idOrKey)) {
$where = 'event_key';
} else {
$where = 'mail_id';
}
$content = Database::fetchAll("SELECT language_id, title, content, event_key\n FROM PREFIX_mails_content AS mc\n LEFT JOIN PREFIX_mails_to_events AS mte\n ON mc.mail_id = mte.mail_id\n WHERE mte." . $where . " = :input", array('input' => $idOrKey));
if (!$content || !count($content)) {
Logger::warning('[Mailer] Template not found for ' . $where . ' ' . $idOrKey);
return false;
}
$data = array();
foreach ($content as $list) {
$data[$list['language_id']] = $list;
}
if (isset($data[$language_id])) {
$template = $data[$language_id];
} else {
$template = reset($data);
}
$template['content'] = html_entity_decode($template['content']);
$status = null;
$event = explode('_', $template['event_key']);
if (count($event) == 4) {
if ($event[2] == 'status' && !empty($event[3])) {
$table = 'PREFIX_' . $event[1] . '_status';
$where = $event[1] . '_status_id';
$id = $event[3];
try {
self::$status = Database::query("SELECT " . $where . " AS id, name FROM " . $table . " WHERE " . $where . " = :id AND language_id = :lang", array('id' => $id, 'lang' => $language_id))->fetch();
self::$status['type'] = strtoupper($event[1][0]) . 'ID.';
} catch (\Exception $e) {
}
}
}
$toReplace = array();
preg_match_all('/{+(.*?)}/', $template['content'], $toReplace);
foreach ($toReplace[1] as $find) {
$template['content'] = self::shortcodeReplacement($find, $template['content']);
}
$toReplace = array();
preg_match_all('/{+(.*?)}/', $template['title'], $toReplace);
foreach ($toReplace[1] as $find) {
$template['title'] = self::shortcodeReplacement($find, $template['title']);
}
return $template;
}
示例15: ajaxGetData
public function ajaxGetData()
{
$type = !empty($this->request->post['type']) ? $this->request->post['type'] : '';
$id = !empty($this->request->post['id']) ? $this->request->post['id'] : 0;
if (!empty($type) && in_array($type, $this->types)) {
$data = array();
$tmp = Database::fetchAll("SELECT language_id, name FROM PREFIX_" . $type . " WHERE " . $type . "_id = :id", array('id' => $id));
if (count($tmp)) {
foreach ($tmp as $list) {
$data['names'][$list['language_id']] = $list['name'];
}
}
$this->response->setOutput(json_encode($data));
}
}