本文整理汇总了PHP中Db::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::escape方法的具体用法?PHP Db::escape怎么用?PHP Db::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::escape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
$retour = false;
$login = Db::escape($_POST['login']);
$getAuth = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . Db::escape(md5($_POST['mdp'])) . "'");
if (Db::num_rows($getAuth) > 0) {
$_SESSION['key'] = true;
// Mise en session de la connexion
$entry = Db::fetch_assoc($getAuth);
$retour = true;
} else {
$getLogin = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'");
if (Db::num_rows($getLogin) > 0) {
$this->login = $login;
$getPwd = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . Db::escape(md5($_POST['mdp'])) . "'");
if (Db::num_rows($getPwd) <= 0) {
$this->errors = "pwd";
}
} else {
$this->errors = "login";
}
$retour = false;
}
return $retour;
}
示例2: changepwd
function changepwd()
{
$retour = true;
$oldpwd = Db::escape($_POST['old']);
$newpwd = Db::escape($_POST['new']);
$verifpwd = Db::escape($_POST['verif']);
$login = Db::escape($_POST['login']);
$getLogin = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'");
if (Db::num_rows($getLogin) > 0) {
$this->login = $login;
$getPwd = Db::query("SELECT * FROM `" . TABLE_PREFIX . "admin` WHERE `login_txt` = '" . $login . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `mdp_txt` = '" . md5($oldpwd) . "'");
if (Db::num_rows($getPwd) > 0) {
if ($newpwd != $verifpwd) {
$this->errors = "changeVerif";
$retour = false;
} else {
Db::query("UPDATE " . TABLE_PREFIX . "admin SET mdp_txt = '" . md5($newpwd) . "' WHERE login_txt = '" . $login . "'");
}
} else {
$this->errors = "pwd";
$retour = false;
}
} else {
$this->errors = "login";
$retour = false;
}
return $retour;
}
示例3: changepwd
function changepwd()
{
$retour = true;
$oldpwd = Db::escape($_POST['old']);
$newpwd = Db::escape($_POST['new']);
$verifpwd = Db::escape($_POST['verif']);
$login = Db::escape($_POST['login']);
$getLogin = Query::connexionLogin($login);
if (Db::num_rows($getLogin) > 0) {
$this->login = $login;
$getPwd = Query::connexion($login, $oldpwd);
if (Db::num_rows($getPwd) > 0) {
if ($newpwd != $verifpwd) {
$this->errors = "changeVerif";
$retour = false;
} else {
Query::updatePassword($newpwd, $login);
}
} else {
$this->errors = "pwd";
$retour = false;
}
} else {
$this->errors = "login";
$retour = false;
}
return $retour;
}
示例4: index
function index($ctx)
{
$page = $_GET['page'] ? intval($_GET['page']) : 0;
$size = $_GET['size'] ? intval($_GET['size']) : 10;
$s = $_GET['s'];
$keyword_type = $_GET['keyword_type'];
$ctx->s = $s;
$ctx->page = $page;
$ctx->size = $size;
$ctx->keyword_type = $keyword_type;
$where = "1";
if ($s || $keyword_type) {
$s2 = Db::escape_like_string($s);
$where .= " and id in(\n\t\t\t\tselect item_id from wx_reply_keywords where 1";
if ($s) {
$where .= " and keyword like '%{$s2}%'";
}
if ($keyword_type) {
$keyword_type = Db::escape($keyword_type);
$where .= " and type='{$keyword_type}'";
}
$where .= ")";
}
$ds = WxReplyItem::paginate($page, $size, $where, 'id desc');
$ctx->ds = $ds;
}
示例5: testQuote
public function testQuote()
{
$vm_ret = $this->db->escape("Editeur d'item de liste");
$this->assertEquals("Editeur d\\'item de liste", $vm_ret);
$vm_ret = $this->db->escape('bar "foo"');
$this->assertEquals('bar \\"foo\\"', $vm_ret);
}
示例6: reset_keywords
function reset_keywords($new_kws_str, $type = 'equal')
{
$ks = $this->keywords();
$old_kws = array();
foreach ($ks as $k) {
$old_kws[] = $k->keyword;
}
$ps = explode(',', $new_kws_str);
$kws = array();
foreach ($ps as $p) {
$p = trim($p);
if (strlen($p)) {
$kws[$p] = $p;
}
}
$to_del = array_diff($old_kws, $kws);
foreach ($to_del as $k) {
Db::escape($k);
$sql = "delete from wx_reply_keywords where item_id='{$this->id}' and keyword='{$k}'";
Db::query($sql);
}
$to_add = array_diff($kws, $old_kws);
foreach ($to_add as $k) {
WxReplyKeyword::save(array('type' => $type, 'keyword' => $k, 'item_id' => $this->id));
}
$sql = "update " . WxReplyKeyword::table() . " set type='{$type}' where item_id='{$this->id}'";
Db::update($sql);
}
示例7: pagination
function pagination($messageParPage, $sscategorie, $search, $searchColumn)
{
/*
paginatio_array 0->Nbre d'enregistrements
paginatio_array 1->Nbre de pages
paginatio_array 2->Pages actuelle
paginatio_array 3->Première entrée
*/
$pagination_array = array();
if (!empty($search)) {
$sqlQuery = "SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . CATEGORIE_NOM . " WHERE sscat_radio = '" . $sscategorie . "' AND ";
for ($i = 0; $i < sizeof($searchColumn); $i++) {
if ($i != 0 && $i != sizeof($searchColumn)) {
$sqlQuery .= "OR ";
}
$sqlQuery .= $searchColumn[$i] . " like '%" . Db::escape($search) . "%' ";
}
} else {
$sqlQuery = "SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . CATEGORIE_NOM . " WHERE sscat_radio = '" . $sscategorie . "'";
}
$getTotal = Db::query($sqlQuery);
$donnees_total = Db::fetch_assoc($getTotal);
$pagination_array[0] = $donnees_total['total'];
$pagination_array[1] = ceil($pagination_array[0] / $messageParPage);
if (isset($_POST['page'])) {
$pagination_array[2] = intval($_POST['page']);
if ($pagination_array[2] > $pagination_array[1] && $pagination_array[1] > 0) {
$pagination_array[2] = $pagination_array[1];
}
} else {
$pagination_array[2] = 1;
}
$pagination_array[3] = ($pagination_array[2] - 1) * $messageParPage;
return $pagination_array;
}
示例8: escapeArray
public static function escapeArray($arr)
{
$escaped = array();
foreach ($arr as $item) {
array_push($escaped, Db::escape($item));
}
return $escaped;
}
示例9: log
/**
* Logs an activity.
* @param string $activity
* @param string $data
*/
public static function log($activity, $data = null)
{
$db = Db::get();
$data = Db::escape(json_encode($data));
if (ENABLE_AUDIT_TRAILS === true && class_exists("SystemAuditTrailModel", false)) {
SystemAuditTrailModel::log(array('item_id' => 0, 'item_type' => 'system_activity', 'description' => $activity, 'type' => SystemAuditTrailModel::AUDIT_TYPE_SYSTEM));
}
}
示例10: getContextoId
/**
* {@inheritDoc}
*/
public function getContextoId($espacialidade, $id)
{
$_id = Db::escape($id);
$tab = MapaTabela::getTabela($espacialidade);
$fk = MapaTabela::getChaveEstrangeira(ESP_REGIAOMETROPOLITANA, $espacialidade);
$sql = sprintf("SELECT \n e.id AS id\n FROM \n estado AS e,\n %s AS t\n WHERE \n t.id=%d \n AND t.%s=e.id", $tab, $_id, $fk);
$this->bd->execSql($sql);
if ($row = $this->bd->proximo()) {
return $row->id;
}
return null;
}
示例11: write
public function write($sessionId, $data)
{
if ($this->new) {
Db::query(sprintf("INSERT into system.sessions(id, data, expires, lifespan) VALUES('%s', '%s', %d, %d)", $sessionId, Db::escape($data), time() + $this->lifespan, $this->lifespan), 'main');
} else {
if ($_GET['no_extend'] == true) {
return true;
} else {
Db::query(sprintf("UPDATE system.sessions SET data = '%s', expires = %d WHERE id = '%s'", db::escape($data), time() + $this->lifespan, $sessionId), 'main');
}
}
return true;
}
示例12: pagination
function pagination($sscategorie, $search, $searchColumn)
{
if (!empty($search)) {
$sqlQuery = "SELECT COUNT(*) AS total FROM `" . TABLE_PREFIX . CATEGORIE_NOM . "` WHERE sscat_radio = '" . $sscategorie . "' AND ";
for ($i = 0; $i < sizeof($searchColumn); $i++) {
if ($i != 0 && $i != sizeof($searchColumn)) {
$sqlQuery .= "OR ";
}
$sqlQuery .= $searchColumn[$i] . " like '%" . Db::escape($search) . "%' ";
}
} else {
$sqlQuery = "SELECT COUNT(*) AS total FROM `" . TABLE_PREFIX . CATEGORIE_NOM . "` WHERE sscat_radio = '" . $sscategorie . "'";
}
return Query::executeQuery($sqlQuery);
}
示例13: suggest
/**
* Generates suggestions for searches based upon input
*/
public static function suggest($ps_phrase, $pa_table_nums = null, $pn_max_suggestions = 1, $pa_options = null)
{
$o_db = new Db();
$va_sql = array();
if ($pa_table_nums && !is_array($pa_table_nums)) {
$pa_table_nums = array(intval($pa_table_nums));
} else {
if (!$pa_table_nums) {
$pa_table_nums = array();
}
}
if (sizeof($pa_table_nums)) {
$va_sql[] = "(p.table_num IN (" . join(', ', $pa_table_nums) . "))";
}
$vs_phrase = preg_replace("![^A-Za-z\\-_0-9]+!", " ", $ps_phrase);
$va_words = preg_split("#[ ]+#", $vs_phrase);
while (sizeof($va_words)) {
$vn_len = strlen($vs_phrase);
$vn_ngram_len = $vn_len - 8;
if ($vn_ngram_len < 3) {
$vn_ngram_len = 3;
}
$va_gen_ngrams = caNgrams($vs_phrase, $vn_ngram_len, false);
$va_ngrams = array();
foreach ($va_gen_ngrams as $vs_ngram) {
if ($vs_ngram) {
$va_ngrams[] = "'" . $o_db->escape($vs_ngram) . "'";
}
}
if (sizeof($va_ngrams)) {
$qr_res = $o_db->query("\n\t\t\t\t\t\tSELECT p.table_num, p.phrase, (count(*) + (sum(n.endpoint) * 2)) score \n\t\t\t\t\t\tFROM ca_did_you_mean_ngrams n \n\t\t\t\t\t\tINNER JOIN ca_did_you_mean_phrases AS p ON p.phrase_id = n.phrase_id WHERE \n\t\t\t\t\t\t\tn.ngram IN (" . join(',', $va_ngrams) . ") " . (sizeof($va_sql) ? ' AND ' . join(' AND ', $va_sql) : '') . "\n\t\t\t\t\t\tGROUP BY p.phrase_id \n\t\t\t\t\t\tORDER BY score DESC, p.num_words DESC, ABS(length(p.phrase) - " . $vn_len . ") ASC\n\t\t\t\t\t\tLIMIT " . intval($pn_max_suggestions));
if ($qr_res->numRows()) {
$va_suggestions = array();
while ($qr_res->nextRow()) {
if (isset($pa_options['groupByTableNum']) && $pa_options['groupByTableNum']) {
$va_suggestions[$qr_res->get('table_num')][] = $qr_res->get('phrase');
} else {
$va_suggestions[$qr_res->get('phrase')] = $qr_res->get('score');
}
}
return $va_suggestions;
}
}
array_pop($va_words);
$vs_phrase = join(' ', $va_words);
}
return array();
}
示例14: insert
function insert($table, $language)
{
$getColumns = mysql_query("SELECT * FROM " . $table);
$column = mysql_fetch_field($getColumns);
while ($column) {
$column = $column->name;
$columnTmp = Utils::findColumn($column, $language);
if (isset($_POST[$columnTmp])) {
Utils::manipulateValues($columnTmp);
//Mise en forme des données pour la BD
$fields[$column] = "'" . Db::escape($_POST[$columnTmp]) . "'";
}
$column = mysql_fetch_field($getColumns);
}
$sql = "INSERT INTO `" . $table . "` (`" . implode("`, `", array_keys($fields)) . "`) VALUES (" . implode(", ", $fields) . ")";
return mysql_query($sql);
}
示例15: select
function select($table, $id = null)
{
if ($id != "0" && empty($id)) {
$sql = "SELECT * FROM `" . $table . "` ORDER BY `id`";
} elseif (is_array($id)) {
$sql = "SELECT * FROM `" . $table . "` WHERE ";
$first = true;
foreach ($id as $col => $val) {
if ($first) {
$first = false;
} else {
$sql .= " AND ";
}
$sql .= "`" . Db::escape($col) . "` = '" . Db::escape($val) . "'";
}
} else {
$sql = "SELECT * FROM `" . $table . "` WHERE `id` = '" . Db::escape($id) . "'";
}
return mysql_query($sql);
}