当前位置: 首页>>代码示例>>PHP>>正文


PHP sql类代码示例

本文整理汇总了PHP中sql的典型用法代码示例。如果您正苦于以下问题:PHP sql类的具体用法?PHP sql怎么用?PHP sql使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sql类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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>";
     }
 }
开发者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/">¬се новости &rarr;</a></p><br><i>¬ принципе, вы можете зайти и ознакомитьс¤ с <a href="/timeline/" target="_self">хронологией моих работ</a> (благо, их пока не так уж много).</i><p align="right"><a href="/card/" target="_self"> арта сайта &rarr;</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


注:本文中的sql类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。