本文整理汇总了PHP中SQL类的典型用法代码示例。如果您正苦于以下问题:PHP SQL类的具体用法?PHP SQL怎么用?PHP SQL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view()
{
RoutingEngine::setPage("runnDAILY View Route", "PV__300");
RoutingEngine::getInstance()->registerParams("rid");
if (!isset($_GET["rid"])) {
Page::redirect("/routes");
}
$rid = $_GET["rid"];
//$route = Route::fromRouteIdentifier($rid);
$route = Route::sql()->select("routes.*, u_username, u_uid")->leftjoin("users", "u_uid", "r_uid", true)->where_eq("r_id", $rid)->execute(true, false);
//get training types for create new training modal
/*$stmt = Database::getDB()->prepare("
SELECT t_type_id, t_type_name
FROM training_types
");
$stmt->execute();
$stmt->store_result();
$types = array();
while($row = $stmt->fetch_assoc()){
$types[] = array("id"=>$row["t_type_id"], "name"=>$row["t_type_name"]);
}
$stmt->close();*/
$types_sql = new SQL("training_types");
$types = $types_sql->select("t_type_id, t_type_name")->execute(false, true);
//$training_items = TrainingLog::getItemsForUserForRoute(User::$current_user->uid, $rid);
$training_items = TrainingLog::sql()->select("r_name, t_rid, t_tid, t_time, t_distance, t_pace, t_date, t_comment")->leftjoin("routes", "r_id", "t_rid")->where_eq("t_uid", User::$current_user->uid)->where_eq("t_rid", $rid)->orderby("t_date")->execute(false, true);
RoutingEngine::getSmarty()->assign("t_types", $types);
RoutingEngine::getSmarty()->assign("route_view", $route);
RoutingEngine::getSmarty()->assign("training_items", $training_items);
}
示例2: fcpf_categories_select
/**
* Get the categories list
*
* @param integer Parent category ID
* @param integer Level
* @return array Categories
*/
function fcpf_categories_select($parent_category_ID = -1, $level = 0)
{
global $blog, $DB;
$result_Array = array();
$SQL = new SQL();
$SQL->SELECT('cat_ID, cat_name');
$SQL->FROM('T_categories');
$SQL->WHERE('cat_blog_ID = ' . $DB->quote($blog));
if ($parent_category_ID == -1) {
$SQL->WHERE_and('cat_parent_ID IS NULL');
} else {
$SQL->WHERE('cat_parent_ID = ' . $DB->quote($parent_category_ID));
}
$SQL->ORDER_BY('cat_name');
$categories = $DB->get_results($SQL->get());
if (!empty($categories)) {
foreach ($categories as $category) {
$result_Array[] = array('value' => $category->cat_ID, 'label' => str_repeat(' ', $level) . $category->cat_name);
$child_Categories_opts = fcpf_categories_select($category->cat_ID, $level + 1);
if ($child_Categories_opts != '') {
foreach ($child_Categories_opts as $cat) {
$result_Array[] = $cat;
}
}
}
}
return $result_Array;
}
示例3: _clean
public static function _clean($max)
{
$db = new SQL(0);
$conn = $db->Verbindungsnr(0);
$max = mysql_real_escape_string(time() - $max, $conn);
return mysql_query("DELETE FROM `user_sessions` WHERE `access` < '{$max}'", $conn);
}
示例4: smarty_function_init_language
function smarty_function_init_language($params, &$smarty)
{
global $site, $leht;
$content_template =& $leht->content_template;
##################
# default values
extract($params);
if (!isset($name)) {
$name = "language";
}
# / default values
###################
$sql = $site->db->prepare("SELECT keel_id AS id, nimi AS name, extension FROM keel WHERE on_kasutusel");
$sth = new SQL($sql);
$sth->debug->msg($sth->debug->get_msgs());
while ($result = $sth->fetch()) {
// if not in editor and use aliases has been enabled
if (!$site->in_editor && $site->CONF['use_aliases']) {
$result['href'] = $site->CONF['wwwroot'] . '/' . $result['extension'];
} else {
$result['href'] = $site->CONF['wwwroot'] . ($site->in_editor ? '/editor' : '') . '/?lang=' . $result['extension'];
}
$result['home_id'] = $site->alias(array('key' => 'rub_home_id', 'keel' => $result['id']));
$language[] = $result;
}
##############
# assign to template variables
$smarty->assign(array($name => $language));
}
示例5: test
public function test()
{
$sql = new SQL();
$doc = $sql->main();
echo $doc;
$this->assertNotEquals($doc, true);
}
示例6: uninstall_b2evolution
/**
* Uninstall b2evolution: Delete DB & Cache files
*/
function uninstall_b2evolution()
{
global $DB;
/* REMOVE PAGE CACHE */
load_class('_core/model/_pagecache.class.php', 'PageCache');
// Remove general page cache
$PageCache = new PageCache(NULL);
$PageCache->cache_delete();
// Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
// Get all blogs
$blogs_SQL = new SQL();
$blogs_SQL->SELECT('blog_ID');
$blogs_SQL->FROM('T_blogs');
$blogs = $DB->get_col($blogs_SQL->get());
$BlogCache =& get_BlogCache('blog_ID');
foreach ($blogs as $blog_ID) {
$Blog = $BlogCache->get_by_ID($blog_ID);
// Remove page cache of current blog
$PageCache = new PageCache($Blog);
$PageCache->cache_delete();
}
}
/* REMOVE DATABASE */
db_delete();
echo '<p>' . T_('Reset done!') . '</p>';
}
示例7: forum_do_edit_stick
function forum_do_edit_stick(&$sqlm)
{
global $forum_lang, $user_lvl, $mmfpm_db;
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
if ($user_lvl == 0) {
error($forum_lang['no_access']);
}
if (!isset($_GET['id'])) {
error($forum_lang['no_such_topic']);
} else {
$id = $sqlm->quote_smart($_GET['id']);
}
if (!isset($_GET['state'])) {
error('Bad request, please mail admin and describe what you did to get this error.');
} else {
$state = $sqlm->quote_smart($_GET['state']);
}
$sqlm->query('
UPDATE mm_forum_posts
SET sticked = ' . $state . '
WHERE id = ' . $id . '');
$sqlm->close();
redirect('forum.php?action=view_topic&id=' . $id . '');
// Queries : 1
}
示例8: TreeSearch
function TreeSearch($searches, $classes, $language_id = 0)
{
global $site;
$this->classes = (array) $classes;
foreach ($this->classes as $i => $class) {
$this->classes[$i] = "'" . mysql_real_escape_string($class) . "'";
}
$sql = 'select tyyp_id from tyyp where klass in (' . implode(',', $this->classes) . ');';
$result = new SQL($sql);
$this->classes = array();
while ($row = $result->fetch('ASSOC')) {
$this->classes[] = $row['tyyp_id'];
}
$where = 'tyyp_id in (' . implode(',', $this->classes) . ') and keel = ' . mysql_real_escape_string($language_id) . ' ';
foreach ($searches as $field => $keyword) {
$where .= ' and ' . mysql_real_escape_string($field);
if ($field == 'objekt_id' || $field == 'ttyyp_id' || $field == 'page_tyyp_id' || $field == 'kesk') {
$where .= ' = ' . (int) $keyword;
} else {
$where .= " like '%" . mysql_real_escape_string($keyword) . "%' ";
}
}
$sql = 'select objekt_id from objekt where ' . $where . ';';
//printr($sql);
$result = new SQL($sql);
while ($row = $result->fetch('ASSOC')) {
$this->found_object_ids[] = $row['objekt_id'];
}
}
示例9: html_header
function html_header()
{
if (!defined('SITE_ROOT')) {
define('SITE_ROOT', './');
}
require SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
$currentUserID = $_SESSION['current_userID'];
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$db->query("SELECT * FROM forum_users WHERE id='{$currentUserID}'");
if ($row = $db->fetch_array()) {
$username = $row['username'];
$realname = $row['realname'];
}
$db->close();
if ($realname !== null) {
$displayname = $realname;
} else {
$displayname = $username;
}
echo '
<div id="wrap">
<div class="navbar navbar-top"><div class="navbar-inner"><div class="container">
<a class="brand" href="#index.php"><div class="logo-ip"></div></a>
<div class="btn-group pull-left">
<a href="../forum" class="btn btn-inverse"><i class="icon-rss"></i> Forum Ishare</a>
</div>
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown"><i class="icon-list muted"></i> KampusLinks <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="http://mpp.eng.usm.my/">MPPUSMKKj Official Blog</a></li>
<li><a href="http://hepp.eng.usm.my/">BHEPP USMKKj</a></li>
<li><a href="http://infodesk.eng.usm.my/">Infodesk PPKT USMKKj</a></li>
<li><a href="http://www.eng.usm.my/php/blockedIP/">Blocked Port List</a></li>
<li><a href="http://elearning.usm.my/">e-Learning Portal</a></li>
<li><a href="http://campusonline.usm.my/">CampusOnline Portal</a></li>
<li><a href="http://www.tcom.usm.my/">Sistem Direktori Telefon USM</a></li>
<li><a href="http://www.facebook.com/ppkt.eng.usm">Facebook PPKT USMKKj</a></li>
<li class="divider"></li>
<li><a href="http://hik3.net/refcode"><i class="icon-bookmark"></i> RefCode (Snippets)</a></li>
</ul>
</div>
<div class="btn-group pull-right">
<a href="index.php" class="btn btn-primary"><i class="icon-home icon-white"></i> Home</a>
<a href="profile.php?id=' . $currentUserID . '" class="btn btn-inverse"><i class="icon-user"></i> ' . $displayname . '</a>
<button class="btn btn-danger dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="edit_profile.php"><i class="icon-edit muted"></i> Edit Profile</a></li>
<li><a href="edit_sharerlink.php"><i class="icon-hdd muted"></i> Edit Sharerlink</a></li>
<li class="divider"></li>
<li><a href="../forum/login.php?action=out&id=' . $currentUserID . '"><i class="icon-off muted"></i> Logout</a></li>
</ul>
</div>
</div></div></div>
';
}
示例10: test
public function test()
{
$sql = new SQL();
echo "Hello";
$doc = $sql->main();
//$doc = false;
$this->assertNotEquals($doc, false);
}
示例11: _load
private static function _load($id)
{
if (isset(self::$_cache[$id])) {
return;
}
$db = new SQL(0);
self::$_cache[$id + 0] = $db->cmdrow(0, 'SELECT * FROM user_list WHERE id={0} LIMIT 0,1', array($id + 0));
}
示例12: smarty_function_init_folders
function smarty_function_init_folders($params, &$smarty)
{
global $site, $leht, $class_path;
include_once $class_path . 'adminpage.inc.php';
##############
# default values
extract($params);
if (!isset($name)) {
$name = 'folders';
}
if (!isset($parent) && !isset($parent_dir)) {
# default parent for file (folder "public/"): get folder ID of "public/"
$sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE relative_path = ? LIMIT 1", $site->CONF['file_path']);
$sth = new SQL($sql);
$folder = $sth->fetch();
$parent_dir = $folder['relative_path'];
$parent = $folder['objekt_id'];
} elseif (isset($parent)) {
# get parent folder info
$parent = (int) $parent;
if ($parent) {
$sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE objekt_id = ?", $parent);
$sth = new SQL($sql);
} else {
return;
}
} elseif (isset($parent_dir)) {
$parent_dir = preg_replace('#^/#', '', $parent_dir);
$parent_dir = preg_replace('#/$#', '', $parent_dir);
$sql = $site->db->prepare("SELECT objekt_id, relative_path FROM obj_folder WHERE relative_path = ? LIMIT 1", '/' . $parent_dir);
$sth = new SQL($sql);
if ($sth->rows == 1) {
$folder = $sth->fetch();
$parent_dir = $folder['relative_path'];
$parent = $folder['objekt_id'];
}
} else {
return;
}
$folders = array();
$folders_from_fm = get_subfolders($parent);
foreach ($folders_from_fm as $folder) {
$obj = new stdClass();
# Bug #2318
$obj->title = $folder['title'];
$obj->path = $folder['relative_path'];
$obj->id = $folder['objekt_id'];
# current folder ID
$obj->parent_id = $folder['parent_id'];
## parent folder ID??
$obj->fullpath = $site->absolute_path . $folder['relative_path'];
# absolute path of the folder
$obj->file_count = $folder['file_count'];
$folders[] = $obj;
}
$smarty->assign($name, $folders);
return;
}
示例13: allread
public static function allread($data)
{
if (!MyUser::isloggedin()) {
throw new APIException("Nicht angemeldet...", 100);
}
$db = new SQL(0);
$db->cmd(0, 'DELETE * FROM user_notification WHERE user = {0}', true, array(MyUser::id()));
return true;
}
示例14: get_realm_name
function get_realm_name($realm_id)
{
global $realm_db;
$sqlr = new SQL();
$sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
$result = $sqlr->query("SELECT name FROM `realmlist` WHERE id = '{$realm_id}'");
$realm_name = $sqlr->result($result, 0);
return $realm_name;
}
示例15: deleteKategorien
/**
* Delete a Categorie in DB
* parameters = POST: Categorie ID
*/
public function deleteKategorien()
{
require 'classes/SQL.php';
$sql = new SQL();
$sql->connect();
$id = mysql_real_escape_string($_POST['id']);
if (is_numeric($id)) {
$sql->doThat('DELETE FROM quizCategories WHERE id=' . $id);
}
}