本文整理汇总了PHP中SafeMySQL::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP SafeMySQL::getAll方法的具体用法?PHP SafeMySQL::getAll怎么用?PHP SafeMySQL::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeMySQL
的用法示例。
在下文中一共展示了SafeMySQL::getAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
function show()
{
$configuration = new Config();
$database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset));
$data = $database->getAll('SELECT * FROM students');
$response = new Response();
$response->setContent(json_encode($data));
$response->send();
}
示例2: userPage
public function userPage($userId)
{
if ($this->accessControl($userId)) {
$db = new SafeMySQL();
$users = $db->getAll('SELECT id,login,name,avatar FROM ?n WHERE id = ?i LIMIT ?i', $this->table, $userId, 1);
$user = array();
if (!empty($users[0]['id'])) {
foreach ($users[0] as $key => $value) {
$user[$key] = $value;
}
}
$userName = empty($user['name']) ? $user['login'] : $user['name'];
$user['page_title'] = "Здравствуйте, " . $userName;
$user['title'] = $userName;
$user['avatar'] = empty($user['avatar']) ? $this->no_avatar : $user['avatar'];
$this->view('user', $user);
} else {
$content['title'] = "УПС!";
$content['message'] = "У вас нет доступа к этой странице. Пожалуйста <a href='/user'>авторизируйтесь</a> чтобы войти!";
$this->view('check', $content);
}
}
示例3: SafeMySQL
<?php
require_once "pass.php";
require_once "lib/safemysql.class.php";
$tableName = "tickets";
echo "Log in MySQL<br>\n";
$db = new SafeMySQL(['host' => $loginData['mysql_host'], 'user' => $loginData['mysql_username'], 'pass' => $loginData['mysql_password'], 'db' => $loginData['mysql_db']]);
echo "<br>List fields in table:<br>\n";
$sql = "SHOW COLUMNS FROM {$tableName}";
$fields = $db->getCol($sql);
//Print table to HTML
?>
<table border="1">
<thead>
<tr>
<?
foreach($fields as $fieldname) {
echo "<td>$fieldname</td>\n";
}
echo "</tr></thead><tbody>";
$data=$db->getAll("SELECT * FROM $tableName ORDER BY dtime DESC LIMIT 100");
foreach($data as $row=>$cols) {
echo"<tr>";
foreach($cols as $col) {
echo " <td>$col</td>\n";
}
echo "</tr>\n";
}
echo "</tbody></table>";
?>
示例4: SafeMySQL
<?php
require '../php/main/SafeMySQL.php';
$string_object = new SafeMySQL();
if ($category === 'all' || !$category) {
$query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10");
} else {
$query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.category=?s AND i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10", $category);
}
$arr = array();
$i = 0;
foreach ($query as $array) {
$image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default';
$link = $category ? $page . '=' . $category . '&video=' . $array['v_id'] : $page . '&video=' . $array['v_id'];
$res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['title'], 'n3' => $array['date'], 'n4' => $array['nickname']);
if (!$i) {
$res = array('head' => '<nav id="content_menu">
<a href="vo=all" class="new_local"><p>ВСЕ</p></a>
<a href="vo=review" class="new_local"><p>ОБЗОРЫ</p></a>
<a href="vo=letsplay" class="new_local"><p>ЛЕТСПЛЕИ</p></a>
<a href="vo=vlog" class="new_local"><p>БЛОГИ</p></a>
<div id="lookatme">
<div class="lookatme"></div>
<div class="lookatme"></div>
<div class="lookatme"></div>
</div>
</nav>
<nav id="content_search"></nav><section id="content_block">', 'tmp' => '<a href="vo&video=%n[0]" class="new_modal">
<article class="video" id="%n[0]" style="background:#000 no-repeat center url(upload_image/videos/pre_500px/%n[1].jpg)">
<div class="video_title">
<p>%n[2]</p>
示例5: json_encode
<?php
require '../php/main/db_connect.php';
require 'mm/parser.php';
$arr = array();
if ($last_id && $page && $user_id) {
$string_object = new SafeMySQL();
$writer = new Writer();
$y = $string_object->getRow("SELECT d_id, other_id, pioneer_id,meter FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $category, $user_id, $category, $user_id);
if ($y['d_id']) {
$dg = $string_object->getAll("SELECT m.text, m.date, m.mes_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND m.mes_id < ?i AND i.user_id = m.user_id ORDER BY m.mes_id DESC LIMIT 10", $y['d_id'], $last_id);
$avatar = $string_object->getOne('SELECT avatar FROM users_information WHERE user_id=?i', $user_id);
$avatar = file_exists('../upload_image/avatars/pre_150px/' . $avatar . '.jpg') ? $avatar : 'default';
$i = 0;
foreach ($dg as $array) {
$res = array('n0' => $y['d_id'], 'n1' => $array['mes_id'], 'n2' => $array['avatar'], 'n3' => $array['nickname'], 'n4' => $array['date'], 'n5' => $writer->main($array['text'], 1));
$i++;
array_push($arr, $res);
}
unset($array);
}
}
print json_encode($arr);
示例6: json_encode
<?php
require '../php/main/SafeMySQL.php';
$o = new SafeMySQL();
$base = $o->getAll('SELECT id,title FROM base_games LIMIT 0,10');
$arr = array();
$i = 0;
foreach ($base as $array) {
$res = array('n0' => $array['id'], 'n1' => $array['title']);
if (!$i) {
$res = array('head' => '<nav id="content_menu">
<a href="be=games" class="new_local"><p>ИГРЫ</p></a>
</nav><nav id="content_search"></nav><section id="content_block">', 'tmp' => '<article id="%n[0]" class="game">
<div class="game_img"></div>
<h4>%n[1]</h4>
</article>', 'footer' => '</section>') + $res;
}
$i++;
array_push($arr, $res);
}
unset($array);
print json_encode($arr);
示例7: SafeMySQL
<?php
require '../php/main/SafeMySQL.php';
if ($last_id) {
$o = new SafeMySQL();
$base = $o->getAll('SELECT id,title FROM base_games WHERE id>?i LIMIT 0,10', $last_id);
$arr = array();
$i = 0;
foreach ($base as $array) {
$res = array('n0' => $array['id'], 'n1' => $array['title']);
$i++;
array_push($arr, $res);
}
unset($array);
print json_encode($arr);
}
示例8: SafeMySQL
<?php
// TODO убрать/переделать
// выбираем список категорий в зависимости от раздела
// используется для аякс-запроса при добавлении записи
if (!empty($_POST['category_list'])) {
include $_SERVER['DOCUMENT_ROOT'] . '/admin/inc/functions.php';
include $_SERVER['DOCUMENT_ROOT'] . '/admin/inc/mysql.class.php';
check_install();
// проверяем, установлена ли cms
$db = new SafeMySQL(array('user' => DB_LOGIN, 'pass' => DB_PASSWORD, 'db' => DB_NAME, 'charset' => 'utf8'));
$rows = $db->getAll('SELECT * FROM ' . DB_PREFIX . '_catalog_subcategories WHERE pid=?i', $_POST['category_list']);
foreach ($rows as $rows2) {
echo '<option value="' . $rows2['id'] . '">' . $rows2['title'] . '</option>';
}
exit;
}
defined('CAFE') or die(header('Location: /'));
check_error();
include 'config.php';
// сохранение настроек
if ($_POST['update-settings']) {
$w_string = '<?php
define ("DEFAULT_CITY", "' . $_POST['default-city'] . '"); // город по умолчанию
define ("DEFAULT_COORD", "' . $_POST['default-coord'] . '"); // начальные координаты
?>';
$fop = fopen($_SERVER["DOCUMENT_ROOT"] . 'admin/modules/catalog/config.php', 'w');
if ($fwr = fwrite($fop, $w_string)) {
fclose($fop);
$message = 'Настройки обновлены';
} else {
示例9: SafeMySQL
<?php
require '../php/main/db_connect.php';
if ($last_id && $page && $user_id) {
$string_object = new SafeMySQL();
$o = $string_object->getAll("SELECT v_id, user_id, title, image, date FROM posts_videos_in WHERE user_id=?i AND v_id<?i ORDER BY v_id DESC LIMIT 0,10", $user_id, $last_id);
$arr = array();
$i = 0;
foreach ($o as $array) {
$image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default';
$res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['title'], 'n3' => $array['date']);
array_push($arr, $res);
$i++;
}
print json_encode($arr);
unset($array);
}