本文整理汇总了PHP中sql::get方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::get方法的具体用法?PHP sql::get怎么用?PHP sql::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginPost
protected static function loginPost()
{
$email = type::post('email', 'string');
$password = type::post('password', 'string');
$remember = type::post('remember', 'int');
if (is_null($email) || is_null($password) || $email == '' || $password == '') {
echo message::info(lang::get('fill_out_both'));
return;
}
$sql = new sql();
$sql->query('SELECT password, salt, id FROM ' . sql::table('user') . ' WHERE `email` = "' . $sql->escape($email) . '"');
if (!$sql->num()) {
echo message::danger(sprintf(lang::get('email_not_found'), htmlspecialchars($email)), true);
$shake = 1;
return;
}
$sql->result();
if (!self::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
echo message::danger(lang::get('wrong_pw'));
$shake = 1;
return;
}
self::loginSession();
self::$userID = $sql->get('id');
$_SESSION['login'] = $sql->get('id');
if ($remember) {
setcookie("remember", $sql->get('id'), time() + 3600 * 24 * 7);
}
}
示例2: getAll
public static function getAll()
{
if (!count(self::$all)) {
$sql = new sql();
$sql->query('SELECT name FROM ' . sql::table('addons') . ' WHERE `install` = 1 AND `active` = 1')->result();
while ($sql->isNext()) {
self::$all[] = $sql->get('name');
$sql->next();
}
}
return self::$all;
}
示例3: News
<?php
/**
* Created by PhpStorm.
* User: Alex Sandiyarov
* Date: 13.12.15
* Time: 12:17
*/
$news = new News();
$a = $news->getAll();
var_dump($a);
//$news->add($data);
//$news->update($title2, $id);
$a = new sql();
$a->get('*', 'news', 'ORDER BY date DESC');
print_r($a->packToArray());
print_r($a->get('*', 'news', 'WHERE id = 4'));
$a->insert('news', 'id, title', '"34543435434534353453455", "sadsadas"');
$a->update('news', 'title = "KUKU"', '4');
示例4: getOne
public function getOne($id)
{
$sql = new sql();
return $sql->get('*', 'news', 'WHERE id = ' . $id);
}
示例5: foreach
foreach ($perms as $key => $val) {
foreach ($val as $var) {
$rights[] = $key . '[' . $var . ']';
}
}
$sql = new sql();
$sql->setTable('user');
$sql->setWhere('id=' . $id);
$admin = isset($_POST['admin']) ? 1 : 0;
$sql->addPost('perms', implode('|', $rights));
$sql->addPost('firstname', type::post('firstname'));
$sql->addPost('name', type::post('name'));
$sql->addPost('email', type::post('email'));
$sql->addPost('admin', $admin);
$sql->addPost('username', type::post('username'));
if (type::post('password') && type::post('password') != $sqlUser->get('password')) {
$sql->addPost('password', userLogin::hash(type::post('password'), $sqlUser->get('salt')));
}
$sql->update();
echo message::success(lang::get('user_edited'));
}
$sql = new sql();
$sql->result("SELECT * FROM " . sql::table('user') . " WHERE id = '" . $sql->escape($id) . "'");
$permTypes = ['server', 'games', 'user'];
$perms = explode('|', $sql->get('perms'));
$permsSplit = [];
foreach ($perms as $value) {
preg_match("~^(\\w+)\\[(\\w+)\\]\$~", $value, $matches);
if (count($matches)) {
$key = $matches[1];
if (!isset($permsSplit[$key])) {
示例6: sortTable
public static function sortTable($table, $sort, $where = '', $select = ['id', 'sort'])
{
if ($where) {
$where = ' WHERE ' . $where;
}
$update = new sql();
$update->setTable($table);
$i = 1;
$sql = new sql();
$sql->query('SELECT `' . $select[0] . '`, `' . $select[1] . '` FROM ' . self::table($table) . $where . ' ORDER BY `' . $select[1] . '` ASC')->result();
while ($sql->isNext()) {
if ($sort == $i) {
$i++;
}
$update->addPost($select[1], $i);
$update->setWhere($select[0] . '=' . $sql->get($select[0]));
$update->update();
$sql->next();
$i++;
}
}