本文整理汇总了PHP中sql::query方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::query方法的具体用法?PHP sql::query怎么用?PHP sql::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: content
function content()
{
$db = new sql();
$db->connect();
if (time() < 1098388800) {
$res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id group by projects.id, name, company, category order by gsum desc");
} else {
$res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id where grade>0 group by projects.id, name, company, category order by gsum desc");
}
$cats = array(1 => "A", "C", "Y");
$tr = "";
while ($data = $db->fetch_array($res)) {
$res1 = $db->query("select * from categories where category_id={$data['category']}");
$data1 = $db->fetch_array($res1);
$url = "/projects/" . $cats[$data1["category_id"]] . "/";
eval('$tr.="' . page::template("modules/resultTR") . '";');
}
if (!$tr) {
$tr = "<p style=\"font-size: 0.85em;\">В настоящее время в данной номинации заявок не подано.</p><p style=\"font-size: 0.85em;\"><a href=\"/request/\">Заявки</a> принимаются до 15 октября 2004 года</p>";
}
$resultTr .= $tr;
if ($resultTr) {
eval('$projectsMain.="' . page::template("modules/resultMain") . '";');
}
$resultTr = "";
if (time() < 1098388800) {
$text = "<p>Здесь размещены текущие результаты голосования, обновляющиеся в режиме реального времени.</p><p>Для того, чтобы проголосовать за проект надо перейти на его страницу.</p><p>Вы можете поставить свою оценку каждому из 22 представленных проектов, но можете сделать это только 1 раз за весь период голосования.</p><p>Голосование открыто до 0:00 22 октября 2004 года.</p>";
} else {
$text = "<h3>Голование закрыто в 0:00 22 октября 2004 года.</h3><p><i>При анализе хода голосования за проекты в интернете, Оргкомитет конкурса М2. Новый Дом 2004. обнаружил многочисленные случаи злоупотребления при выставлении оценки 0 баллов. В целях повышения релевантности итогов голосования, Оргкомитет принял решение не учитывать оценки 0 баллов, выставленные за весь период голосования в интернете.</i></p>";
}
$this->elements["content"] = $text . $projectsMain;
}
示例2: regKunde
function regKunde()
{
$fornavn = $this->fornavn;
$etternavn = $this->etternavn;
$adresse = $this->adresse;
$postnr = $this->postnr;
$telefonnr = $this->telefonnr;
$epost = $this->epost;
$db = new sql();
$resultat = $db->query("INSERT INTO webprosjekt_kunde (Fornavn,Etternavn,Adresse,PostNr,Telefonnr,Epost,Passord)" . " VALUES('{$fornavn}','{$etternavn}','{$adresse}','{$postnr}','{$telefonnr}','{$epost}','temporary')");
$KNr = $db->insert_id;
if ($db->affected_rows < 1) {
return "<p class=\"feilmelding\">Databasefeil ved registrering av ny bruker. Vennligst forsøk på nytt eller ta kontakt med supporten. (Errno NK01)</p>";
}
$passord = genPassord();
$dbPassord = cryptPass($passord, $KNr . $epost);
$resultat = $db->query("UPDATE webprosjekt_kunde SET Passord='{$dbPassord}' WHERE KNr='{$KNr}'");
if ($db->affected_rows < 1) {
return "<p class=\"feilmelding\">Databasefeil ved registrering av ny bruker. Vennligst forsøk på nytt eller ta kontakt med supporten. (Errno NK02)</p>";
}
$db->close();
$emne = "Registrering i Nettbutikken";
$tekst = "Hei\r\n\r\n" . "Din nye bruker i HBHL nettbutikk er nå registrert.\r\n\r\n" . "Her er din innloggingsinformasjon:\r\n" . "Brukernavn: {$epost} \r\n" . "Passord: {$passord} \r\n\r\n" . "For å logge inn, gå til http://nettbutikk.henrikh.net/ \r\n" . "Du kan selvsagt bytte passord når du har logget inn.\r\n\r\n" . "Hilsen,\r\nHiranBårdHenrikLars.";
$hode = 'From: nettbutikk@henrikh.net' . "\r\n" . 'Reply-To: nettbutikk@henrikh.net' . "\r\n" . 'Content-type: text/plain; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$resultat = @mail($epost, $emne, $tekst, $hode);
if ($resultat) {
return "<p class=\"okmelding\">Brukeren din har nå blitt opprettet. Brukernavn og passord er sendt på e-post til {$epost}.</p>" . "<p>Du kan nå <a href=\"index.php?side=logginn\">logge inn</a>.</p>";
} else {
return "<p class=\"okmelding\">Brukeren din har nå blitt opprettet.</p>" . "<p>Her er din innloggingsinformasjon:<br>" . "Brukernavn: {$epost} <br>" . "Passord: {$passord} </p>" . "<p>Du kan nå <a href=\"index.php?side=logginn\">logge inn</a>.</p>";
}
}
示例3: defaultAction
function defaultAction()
{
global $HTTP_SERVER_VARS;
include "./lib/config.inc.php";
$db = new sql();
$db->connect();
$result = $db->query('SELECT VERSION() AS version');
if ($result != FALSE && $db->num_rows($result) > 0) {
$row = $db->fetch_array($result);
$match = $row['version'];
} else {
$result = $db->query('SHOW VARIABLES LIKE \'version\'');
if ($result != FALSE && $db->num_rows($result) > 0) {
$row = $db->fetch_array($result);
$match = $row[1];
}
}
$this->MYSQL_VER = $match;
$this->PHP_OS = PHP_OS;
$this->PHP_VERSION = PHP_VERSION;
$this->CMS = $admin_config["name"] . " " . $admin_config["version"];
$this->AUTHOR = $admin_config["author"];
$this->HOME_PAGE = $admin_config["home_page"];
$content = admin::template("info", $this);
$this->elements["content"] = $content;
}
示例4: setRecord
public function setRecord($data)
{
extract($data);
if ($action == "users") {
if (!empty($edit)) {
// редактирование
$sql = "UPDATE users\n SET nik='{$nik}',\n fullname='{$fullname}',\n position='{$position}',\n password='{$password1}'\n WHERE id='{$edit}'";
} else {
// добавление
$sql = "INSERT INTO users (nik,fullname,position,password)\n VALUES ('{$nik}','{$fullname}','{$position}','{$password1}')";
}
sql::query($sql);
} else {
$sql = "DELETE FROM rights WHERE u_id='{$userid}'";
sql::query($sql);
if (!empty($r)) {
foreach ($r as $key => $val) {
foreach ($val as $k => $V) {
$sql = "INSERT INTO rights (u_id,type_id,rtype_id,rights.right) VALUES ('{$userid}','{$key}','{$k}','1')";
sql::query($sql);
}
}
}
// почистить сессию для того чтоб вступили права пользователь должен перезайти
//$sql = "DELETE FROM session WHERE u_id='{$userid}'";
//sql::query($sql);
}
return sql::affected();
}
示例5: delete
function delete($key)
{
if (isset($this->data[$key])) {
unset($this->data[$key]);
sql::query('DELETE FROM ' . _TABLE_PREFIX_ . 'config WHERE name="' . addslashes($key) . '"');
}
}
示例6: 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);
}
}
示例7: delete
public function delete($delete)
{
$affected = 0;
$sql = "DELETE FROM orders WHERE id='{$delete}'";
sql::query($sql);
$affected += sql::affected();
// удаление связей
$sql = "DELETE FROM files WHERE `table`='orders' AND rec_id='{$delete}'";
sql::query($sql);
$affected += sql::affected();
$sql = "SELECT * FROM tz WHERE order_id='{$delete}'";
$res = sql::fetchAll($sql);
foreach ($res as $rs) {
// удаление
$delete = $rs["id"];
$sql = "DELETE FROM tz WHERE id='{$delete}'";
sql::query($sql);
$affected += sql::affected();
// удаление связей
$sql = "SELECT * FROM posintz WHERE tz_id='{$delete}'";
$res1 = sql::fetchAll($sql);
foreach ($res1 as $rs1) {
$delete = $rs1["id"];
$sql = "DELETE FROM posintz WHERE id='{$delete}'";
sql::query($sql);
$affected += sql::affected();
}
}
return $affected;
}
示例8: language
function language($language, $site, $load = false)
{
$res = sql::query("\r\n\t\t \tSELECT \r\n\t\t\t\t *\r\n\t\t\t FROM\r\n \t\t\t\t" . _TABLE_PREFIX_ . "language\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tid = '" . addslashes($language) . "' AND\r\n\t\t\t\t\tsite = '" . addslashes($site) . "'\r\n\t\t ");
if ($row = sql::fetch_array($res)) {
$this->id = $row['id'];
$this->name = $row['name'];
$this->public = !!$row['public'];
} else {
$this->id = 'en';
$this->name = 'English';
$this->public = false;
}
@(include _BASE_LIBRARIES_ . 'resources/iso639to3166.php');
$this->flag = strtolower($iso639to3166[$this->id]);
if ($load) {
// Load english strings first...
$res = @mysql_query("\r\n\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t* \r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "strings\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tlanguage = 'en'\r\n\t\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->strings[$row['id']] = $row['value'];
}
if ($language != 'en') {
$res = sql::query("\r\n\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\t* \r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "strings\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tlanguage = '" . addslashes($language) . "'\r\n\t\t\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->strings[$row['id']] = $row['value'];
}
}
}
}
示例9: event_CreateRevision
function event_CreateRevision(&$data)
{
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_seo\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tID = '" . $data['id'] . "' AND\r\n\t\t\t\t\trevision = '" . $data['from'] . "'\r\n\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
sql::query("\r\n\t\t\t\t\tINSERT INTO \r\n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_seo \r\n\t\t\t\t\tSET \r\n\t\t\t\t\t\tID='" . $data['id'] . "', \r\n\t\t\t\t\t\trevision='" . $data['to'] . "',\r\n\t\t\t\t\t\tkeywords='" . addslashes($row['keywords']) . "',\r\n\t\t\t\t\t\tdescription='" . addslashes($row['description']) . "'\r\n\t\t\t\t");
}
}
示例10: defaultAction
function defaultAction()
{
$db = new sql();
$db->connect();
$chid = $this->chid;
include "lib/pagination.class.php";
include "lib/orderby.class.php";
$adminConfig = admin::adminConfig();
for ($i = 1; $i < 4; $i++) {
$voteTR = "";
$orderBy = new orderBy("?chid=" . $this->chid . "&", array("id" => "№", "time" => "Дата", "name" => "Заголовок", "company" => "Компания", "gsum" => "Средний бал", "gcount" => "Проголосовало"), array("gsum" => "desc"), $this->field[$i], $this->order[$i], array("field[{$i}]", "order[{$i}]"));
$pagination = new pagination($orderBy->urlForPage(), $this->page, $adminConfig["recPerPage"], '', "projects", "id");
$res = $db->query("select projects.id, name, company, category_name, date, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM (projects LEFT JOIN categories ON projects.category = categories.category_id) left join votes on projects.id=votes.id where category={$i} group by projects.id, name, company, category_name, date " . $orderBy->orderByQuery() . " " . $pagination->limit());
$page = $this->page ? "&page=" . $this->page : "";
while ($data = $db->fetch_array($res)) {
$data["date"] = date("d.m.Y", $data["date"]);
eval('$voteTR.="' . admin::template("voteTR") . '";');
}
$pageBar = $pagination->bar();
$th = $orderBy->bar();
eval('$content.="' . admin::template("voteMain") . '";');
$content .= "<br>";
}
$this->elements["content"] = $content;
}
示例11: _changeLanguage
function _changeLanguage($id, $language)
{
$res = sql::query("\r\n\t\t\t\tUPDATE \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tSET \r\n\t\t\t\t\tlanguage = '" . addslashes($language) . "'\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tID='" . $id . "'\r\n\t\t\t");
$res = sql::query("\r\n\t\t\t\tSELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tparent = '" . $id . "'\r\n\t\t\t");
while ($row = sql::fetch_array($res, MYSQL_ASSOC)) {
$this->_changeLanguage($row['ID'], $language);
}
}
示例12: delete
public function delete($delete)
{
$affected = 0;
$sql = "DELETE FROM posintz WHERE id='{$delete}'";
sql::query($sql);
$affected += sql::affected();
return $affected;
}
示例13: setRecord
public function setRecord($data)
{
extract($data);
$sql = "INSERT INTO {$this->maintable} (`key`,`description`) VALUES ('{$key}','{$description}')";
sql::query($sql);
$ret[affected] = true;
return $ret;
}
示例14: delete
public function delete($delete)
{
$sql = "DELETE FROM blocks WHERE id='{$delete}'";
sql::query($sql);
$sql = "DELETE FROM blockpos WHERE block_id='{$delete}'";
sql::query($sql);
return sql::affected();
}
示例15: __construct
public function __construct($id)
{
if ($id) {
$sql = new sql();
$sql->query('SELECT * FROM ' . sql::table('user') . ' WHERE id=' . $id)->result();
$this->entrys = $sql->result;
$this->entrys['perms'] = explode('|', $this->get('perms'));
}
}