本文整理汇总了PHP中sql类的典型用法代码示例。如果您正苦于以下问题:PHP sql类的具体用法?PHP sql怎么用?PHP sql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sql类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\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>";
}
}
开发者ID:henrikhermansen,项目名称:Webprogprosjekt,代码行数:31,代码来源:kunde_ny.php
示例2: check_login_info
function check_login_info($_username, $_password) {
$sql = new sql();
$query = "select id, password, date_creation from qcs_users where username = '".$_username."'";
$rs = $sql -> dquery($query);
if ($rs[0] > 0) {
$date_creation = substr($rs[1]['date_creation'], 0, 10);
$input_password = md5(md5($_password).$date_creation);
$db_password = $rs[1]['password'];
$user_id = $rs[1]['id'];
if ($input_password != $db_password)
$user_id = -1;
// echo "password = " . $_password;
// echo "rs[1]['password'] = " . $rs[1]['password'];
// exit();
if($rs[1]['password'] == md5($_password))
$user_id = $rs[1]['id'];
}
else $user_id = -1;
$sql -> dclose();
return $user_id;
}
开发者ID:qcstw-dev,项目名称:qcsasia,代码行数:30,代码来源:login.php
示例3: 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);
}
}
开发者ID:DINKIN,项目名称:rokket,代码行数:29,代码来源:login.php
示例4: FillArray
/**
* Fill an array with the data of Articles, which is ready to paste in a ComaLate-Template
* @access public
* @param integer Maximum The maximum count of Articles, which should be loaded, if it is -1 all Articles will be loaded
* @param boolean ParserDate Should the timsamp of each article parsed to a hunam-readable value?
* @param boolean DisplayAutor Put the author into the array? if it's 'false' the value of the config is decisive if not the name will be shown
* @return array A ComaLate ready Array
*/
function FillArray($Maximum = 6, $ParserDate = true, $DisplayAuthor = false)
{
$entries = array();
$sql = "SELECT *\n\t\t\t\tFROM " . DB_PREFIX . "articles\n\t\t\t\tORDER BY article_date DESC\n\t\t\t\tLIMIT 0, {$Maximum}";
// if $Maximum is -1 then show all entries
if ($Maximum == -1) {
$sql = "SELECT *\n\t\t\t\t\tFROM " . DB_PREFIX . "news\n\t\t\t\t\tORDER BY date DESC";
}
$entriesResult = $this->_SqlConnection->SqlQuery($sql);
$displayAuthor = false;
if ($this->_Config->Get('news_display_author', 1) == 1) {
$displayAuthor = true;
}
if ($DisplayAuthor) {
$displayAuthor = true;
}
$dateFormat = '';
// get the date-format-string if the date should be human-readable
if ($ParserDate) {
$dateFormat = $this->_Config->Get('news_date_format', 'd.m.Y');
$dateFormat .= ' ' . $this->_Config->Get('news_time_format', 'H:i:s');
}
// paste all entries into the array
while ($entrie = mysql_fetch_object($entriesResult)) {
$newsAuthor = '';
// set the author if it should be so
if ($displayAuthor) {
$newsAuthor = $this->_ComaLib->GetUserByID($entrie->userid);
}
$entries[] = array('NEWS_DATE' => $ParserDate ? date($dateFormat, $entrie->date) : $entrie->date, 'NEWS_TEXT' => nl2br($entrie->text), 'NEWS_AUTHOR' => $newsAuthor, 'NEWS_TITLE' => $entrie->title, 'NEWS_ID' => $entrie->id);
}
return $entries;
}
开发者ID:BackupTheBerlios,项目名称:comacms-svn,代码行数:41,代码来源:articles.class.php
示例5: logout
function logout()
{
$sql = new sql();
$table = "session";
$campos = "date_logout=now()";
$where = "session='" . $_SESSION['session'] . "'";
$sql->update($table, $campos, $where, 'N');
$_SESSION['cod_usuario'] = "";
$_SESSION['user'] = "";
$_SESSION['loged'] = false;
$_SESSION['session'] = "";
$_SESSION['cod_empresa'] = "";
$_SESSION['razao_social'] = "";
$_SESSION['endereco'] = "";
$_SESSION['numero'] = "";
$_SESSION['complemento'] = "";
$_SESSION['cep'] = "";
$_SESSION['cidade'] = "";
$_SESSION['uf'] = "";
$_SESSION['cnpj'] = "";
$_SESSION['logo'] = "";
$_SESSION['email'] = "";
$_SESSION['telefone'] = "";
//header("Location: index.php");
}
开发者ID:sergioflorencio,项目名称:toucan,代码行数:25,代码来源:login.php
示例6: 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;
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:25,代码来源:vote.class.php
示例7: getUpdateDate
static function getUpdateDate($format = 'd.m.Y')
{
global $REX;
$query = 'SELECT updatedate FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE updatedate <> 0 ORDER BY updatedate DESC LIMIT 1';
$sql = new sql();
$sql->setQuery($query);
return date($format, $sql->getValue('updatedate'));
}
开发者ID:olien,项目名称:be_utilities,代码行数:8,代码来源:class.rex_update_date.inc.php
示例8: email_exists
function email_exists($_email) {
$sql = new sql();
$query = "select id from member where email = '".$_email."'";
$rs = $sql -> dquery($query);
$sql -> dclose();
if ($rs[0] > 0) return FALSE;
else return TRUE;
}
开发者ID:qcstw-dev,项目名称:qcsasia,代码行数:9,代码来源:tools.php
示例9: __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'));
}
}
开发者ID:DINKIN,项目名称:rokket,代码行数:9,代码来源:user.php
示例10: rightBar
function rightBar()
{
$db = new sql();
$db->connect();
$res = $db->query(" select * from news order by time desc limit 0, 3");
while ($data = $db->fetch_array($res)) {
$this->elements["rightBar"] .= '<table><tr><th>' . $data["title"] . ':</th></tr><tr><td>' . $data["text"] . '</td></tr></table>';
}
$this->elements["rightBar"] = '<td valign="top" style="padding-left: 1em;">' . $this->elements["rightBar"] . '<p align="right"><a href="/news/">¬се новости →</a></p><br><i>¬ принципе, вы можете зайти и ознакомитьс¤ с <a href="/timeline/" target="_self">хронологией моих работ</a> (благо, их пока не так уж много).</i><p align="right"><a href="/card/" target="_self"> арта сайта →</a></p></td>';
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:10,代码来源:index.class.php
示例11: getAllProjects
function getAllProjects()
{
global $TABLE_PREFIX;
$sql = new sql();
$sql->query("SELECT * FROM " . $TABLE_PREFIX . "projects;");
$ret = array();
while ($row = $sql->getNextRow()) {
array_push($ret, $row);
}
return $ret;
}
开发者ID:nhandler,项目名称:whube,代码行数:11,代码来源:project.php
示例12: getAllBugs
function getAllBugs()
{
global $TABLE_PREFIX;
$sql = new sql();
$sql->query("SELECT * FROM " . $TABLE_PREFIX . "bugs ORDER BY bID DESC;");
$ret = array();
while ($row = $sql->getNextRow()) {
array_push($ret, $row);
}
return $ret;
}
开发者ID:nhandler,项目名称:whube,代码行数:11,代码来源:bug.php
示例13: searchCategoryByName
/**
* @access public
*/
function searchCategoryByName($name)
{
$query = 'SELECT id FROM ' . OOMedia::getTableName() . ' WHERE name = "' . addslashes($name) . '"';
$sql = new sql();
$result = $sql->get_array($query);
$media = array();
foreach ($result as $line) {
$media[] = OOMediaCategory::getCategoryById($line['id']);
}
return $media;
}
开发者ID:BackupTheBerlios,项目名称:redaxo,代码行数:14,代码来源:class.oomediacategory.inc.php
示例14: appendEdit
function appendEdit()
{
$this->fields["time"] = mktime(0, 0, 0, $this->date["month"], $this->date["day"], $this->date["year"]);
foreach ($this->fields as $key => $value) {
$query .= "{$key}='{$value}', ";
}
$query = substr($query, 0, strlen($s) - 2);
$db = new sql();
$db->connect();
$db->query("update news set {$query} where id=" . $this->fields["id"]);
header("Location: ?chid=" . $this->chid . "&m=3");
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:12,代码来源:news.class.php
示例15: 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;
}
开发者ID:DINKIN,项目名称:rokket,代码行数:12,代码来源:config.php
示例16: _rex_installDump
function _rex_installDump($file, $debug = false)
{
$sql = new sql();
$sql->debugsql = $debug;
$error = '';
foreach (readSqlDump($file) as $query) {
$sql->setQuery($query);
if (($sqlerr = $sql->getError()) != '') {
$error .= $sqlerr . "\n<br/>";
}
}
return $error;
}
开发者ID:BackupTheBerlios,项目名称:gbforredaxo,代码行数:13,代码来源:function_rex_installation.inc.php
示例17: got_child
function got_child($id)
{
$db = new sql();
$db->connect();
$res = $db->query(_QUERY . " where pid={$id}");
if ($db->num_rows($res) > 0) {
return true;
exit;
} else {
return false;
exit;
}
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:13,代码来源:links.php
示例18: CHECKONOFFSTATUS
function CHECKONOFFSTATUS()
{
$db = new sql();
$today = date("Ymd");
$sql = "\n\tSELECT id,status\n\tFROM rex_article WHERE\n\t(online_von <= '{$today}' AND online_von != '' AND online_bis = '' AND status='0')\n\tOR\n\t(online_von <= '{$today}' AND online_von != '' AND online_bis >= '{$today}' AND status='0')\n\tOR\n\t(online_von = '' AND online_bis >= '{$today}' AND status='0')\n\tOR\n\t(online_von < '{$today}' AND online_bis < '{$today}' AND online_von != '' AND online_bis != '' AND status='0')\n\tOR\n\t(online_bis < '{$today}' AND online_bis != '' AND online_von = '' AND status='1')\n\tOR\n\t(online_bis < '{$today}' AND online_bis != '' AND online_von > '{$today}' AND status='1')\n\tOR\n\t(online_bis < '{$today}' AND online_von < '{$today}' AND online_von != '' AND online_bis != '' AND status='1')\n\tOR\n\t(online_bis > '{$today}' AND online_von > '{$today}' AND online_von != '' AND online_bis != '' AND status='1')\n\t";
$result = $db->get_array($sql);
if (is_array($result)) {
foreach ($result as $var) {
$status = $var[status] == 0 ? 1 : 0;
$sql = "UPDATE rex_article SET status = '{$status}' WHERE id='{$var['id']}'";
$db->setQuery($sql);
}
}
}
开发者ID:BackupTheBerlios,项目名称:redaxo,代码行数:14,代码来源:function_onoff.inc.php
示例19: rex_glossar_replace
/**
* Glossar Addon
* <
* @author staab[at]public-4u[dot]de Markus Staab
* @author <a href="http://www.public-4u.de">www.public-4u.de</a>
* @package redaxo3
* @version $Id: function_replace.inc.php,v 1.4 2008/01/25 09:48:36 kills Exp $
*/
function rex_glossar_replace($params)
{
global $REX, $mypage, $I18N_GLOSSAR;
$string = $params['subject'];
// Aufteilen des Strings, damit nur im Body ersetzt wird
$bodystart = strpos($string, '<body>');
$header = substr($string, 0, $bodystart);
$body = substr($string, $bodystart);
// Bereiche ersetzen, in denen keine Glossar ersetzungen durchgeführt werden sollen
// welche nicht innerhalb des Tags sind
$back_srch = array();
$back_rplc = array();
$mtchs = array();
if (preg_match_all('/(<textarea.*?>(.*?)<\\/textarea>)/s', $body, $mtchs)) {
foreach ($mtchs[2] as $key => $mtch) {
$back_srch[$key] = '###SPACER###' . $key . '###';
$back_rplc[$key] = $mtch;
$body = str_replace($mtch, '###SPACER###' . $key . '###', $body);
}
}
$sql = new sql();
//$sql->debugsql = true;
$sql->setQuery('SELECT * FROM rex_13_glossar, rex_13_glossar_lang WHERE language = lang_id ORDER BY CHAR_LENGTH(shortcut) DESC');
// IE doesnt support <abbr>
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
$replacetag = 'acronym';
} else {
$replacetag = 'abbr';
}
$replaceformat = '<' . $replacetag . ' class=\\"abbr\\" title=\\"%desc% (%lang%)\\">%short%</' . $replacetag . '>';
$searches = array();
$replaces = array();
for ($i = 0; $i < $sql->getRows(); $i++) {
$language = htmlspecialchars($sql->getValue('lang_name'));
$shortcut = htmlspecialchars($sql->getValue('shortcut'));
$description = htmlspecialchars($sql->getValue('description'));
$casesense = $sql->getValue('casesense');
// Escape Shortcut for preg_match
$escapedshortcut = preg_quote($shortcut, '/');
$escapedentitiesshortuct = htmlentities($escapedshortcut);
if ($escapedentitiesshortuct == $escapedshortcut) {
$search = '/((<[^>]*)|' . $escapedshortcut . ')/e';
} else {
$search = '/((<[^>]*)|' . $escapedshortcut . '|' . $escapedentitiesshortuct . ')/e';
}
$replacer = _rex_glossar_parse_replace_format($replaceformat, array('lang' => $language, 'desc' => $description, 'short' => $shortcut));
$replace = '"\\2"=="\\1" && strpos( "\\1", "<' . $replacetag . '>") === false ? "\\1":"' . $replacer . '"';
if ($casesense == 0) {
$search .= 'i';
}
$searches[] = $search;
$replaces[] = $replace;
$sql->next();
}
// Ersetzungen durchführen
$body = stripslashes(preg_replace($searches, $replaces, $body));
// Vorher ausgeschlossene Bereiche wieder einpflegen
$body = str_replace($back_srch, $back_rplc, $body);
return $header . $body;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-addons,代码行数:68,代码来源:function_replace.inc.php
示例20: 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;
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:26,代码来源:content.class.php
注:本文中的sql类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论