本文整理汇总了PHP中resource::quote方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::quote方法的具体用法?PHP resource::quote怎么用?PHP resource::quote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::quote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stripslashes
function q_str($value, $addquote = true)
{
if (!$this->conn) {
$this->connect();
}
if (is_bool($value)) {
return $value ? 1 : 0;
}
if (is_null($value)) {
return 'NULL';
}
$value = stripslashes($value);
if ($this->type == "PDO") {
if ($addquote) {
return $this->conn->quote($value);
} else {
return $value;
}
} else {
if ($this->type == "SQLite3") {
$value = $this->conn->escapeString($value);
return $addquote ? "'" . $value . "'" : $value;
} else {
$value = sqlite_escape_string($value);
return $addquote ? "'" . $value . "'" : $value;
}
}
}
示例2: quoteTrustedValue
/**
* Quote Trusted Value
*
* The ability to quote values without notices
*
* @param $value
* @return mixed
*/
public function quoteTrustedValue($value)
{
if ($this->resource instanceof \PDO) {
return $this->resource->quote($value);
}
return '\'' . str_replace('\'', '\'\'', $value) . '\'';
}
示例3: addItems
/**
* Add items on the database
*
* @param Integer $feed_id ToDo desc
* @param Array $items ToDo desc
*
* @return void
*/
public function addItems($feed_id, $items)
{
if (empty($items)) {
return;
}
$items = array_slice($items, 0, intval($this->getConfig('FeedTicker.itemsLimit', 5)));
$dli = intval($this->getConfig('FeedTicker.dateLimit', 60 * 60 * 24 * 7));
$dateLimit = time() - $dli;
$q = $this->db->prepare('INSERT INTO ft_items (
feed_id, updated, title, link, author, read
) VALUES (
:feed_id, :updated, :title, :link, :author, :read
)');
foreach ($items as $i) {
if (!empty($i['updated']) and $i['updated'] < $dateLimit) {
continue;
}
// Check if this item already exists
$sql = 'SELECT COUNT(*) FROM ft_items WHERE feed_id = ' . $this->db->quote($feed_id) . ' AND link = ' . $this->db->quote(trim($i['link']));
$opa = $this->db->query($sql)->fetchColumn();
if ((bool) $this->db->query($sql)->fetchColumn()) {
continue;
}
$q->execute(array(':feed_id' => $feed_id, ':updated' => trim($i['updated']), ':title' => trim($i['title']), ':link' => trim($i['link']), ':author' => trim($i['author']), ':read' => 0));
}
}
示例4: escapeString
/**
* {@inheritDoc}
*
* @param string $str string to escape
* @return string a string which is safe to insert into the db
*/
function escapeString($str)
{
return substr($this->pdo->quote($str), 1, -1);
/*
pdo->quote adds quotes around string rather than
just escape. As existing code then adds an additional
pair of quotes we need to strip inner quotes
*/
}
示例5: quoteTrustedValue
/**
* Quote Trusted Value
*
* The ability to quote values without notices
*
* @param $value
* @return mixed
*/
public function quoteTrustedValue($value)
{
if (is_resource($this->resource)) {
return '\'' . pg_escape_string($this->resource, $value) . '\'';
}
if ($this->resource instanceof \PDO) {
return $this->resource->quote($value);
}
return '\'' . addcslashes($value, "\n\r\\'\"") . '\'';
}
示例6: qstr
/**
* 转义字符串
*
* @param string $value
* @return mixed
*/
function qstr($value)
{
if (is_bool($value)) {
return $value ? $this->TRUE_VALUE : $this->FALSE_VALUE;
}
if (is_null($value)) {
return $this->NULL_VALUE;
}
return $this->conn->quote($value);
}
示例7: escapeString
/**
* Add escape characters for importing data
*
* @param string $str String to parse
* @return string
*/
public function escapeString($string)
{
try {
$string = $this->connection->quote($string);
return substr($string, 1, -1);
} catch (PDOException $e) {
$this->_loadError($link, $e);
}
return false;
}
示例8: quoteTrustedValue
/**
* {@inheritDoc}
*/
public function quoteTrustedValue($value)
{
if ($this->resource instanceof DriverInterface) {
$this->resource = $this->resource->getConnection()->getResource();
}
if ($this->resource instanceof \PDO) {
return $this->resource->quote($value);
}
return '\'' . str_replace('\'', '\'\'', $value) . '\'';
}
示例9: quoteTrustedValue
/**
* {@inheritDoc}
*/
public function quoteTrustedValue($value)
{
if ($this->resource instanceof DriverInterface) {
$this->resource = $this->resource->getConnection()->getResource();
}
if (is_resource($this->resource)) {
return '\'' . pg_escape_string($this->resource, $value) . '\'';
}
if ($this->resource instanceof \PDO) {
return $this->resource->quote($value);
}
return 'E' . parent::quoteTrustedValue($value);
}
示例10: escape
public function escape($string)
{
if (get_magic_quotes_runtime()) {
$string = stripslashes($string);
}
if (function_exists($this->db->real_escape_string)) {
return $this->db->real_escape_string($string);
} elseif (function_exists($this->db->quote)) {
return $this->db->quote($string);
} else {
return $string;
}
}
示例11: quote
/**
* Quote a string for a quote. Note you should generally use a bind!
* @param string $val Value to quote
* @param string $type Value type
* @return string
*/
public function quote($val, $type = \PDO::PARAM_STR)
{
return $this->_db->quote($val, $type);
}
示例12: purgeOldCodesFromDatabase
/**
* Deletes old codes from sqlite database
*/
protected function purgeOldCodesFromDatabase()
{
if ($this->use_database && $this->pdo_conn) {
$now = time();
$limit = !is_numeric($this->expiry_time) || $this->expiry_time < 1 ? 86400 : $this->expiry_time;
$query = sprintf("DELETE FROM %s WHERE %s - created > %s", $this->database_table, $this->pdo_conn->quote($now, PDO::PARAM_INT), $this->pdo_conn->quote($limit, PDO::PARAM_INT));
$result = $this->pdo_conn->query($query);
}
}
示例13: migration_save
/** Save migration status to database
*
* @param resource $db DB link
* @param string $file_name Migration file name
*
* @return boolean true on success, false on failure
*/
function migration_save($db, $file_name)
{
$query = "INSERT INTO migrations (version, apply_time) VALUES(" . $db->quote($file_name, 'text') . "," . $db->quote(time(), 'text') . ")";
return $db->query($query);
}
示例14: escape
/**
* escape
* @param string $sql
* @param resource $connResource
* @return string
*/
public function escape($sql, $connResource)
{
// quote返回值带最前面和最后面的单引号, 这里去掉, DbHandler中加
return trim($connResource->quote($sql), "'");
}
示例15: quote
/**
* Quotes a string for use in a query.
*
* @param string $string string to quote
*
* @return string
* @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
*/
public function quote($string)
{
$this->deprecated();
return $this->conn->quote($string);
}