本文整理汇总了PHP中DBConnect::escape_string方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnect::escape_string方法的具体用法?PHP DBConnect::escape_string怎么用?PHP DBConnect::escape_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnect
的用法示例。
在下文中一共展示了DBConnect::escape_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_metadata
/**
*
* @param <type> $metadata
*/
public function set_metadata($metadata)
{
self::validate_content($metadata, DBDataType::DATATYPE_TEXT);
try
{
$metadata = $this->db->escape_string($metadata);
$this->db->quick_query(
"UPDATE ".self::FCORE_FORUM." SET
".self::METADATA."='$metadata' WHERE
".self::FORUM_ID."=$this->forum_id");
$this->db->commit();
}
catch(Exception $e)
{
$this->db->rollback();
throw new DBForumException($e->getMessage());
}
}
示例2: consume_identifier
/**
*
* @param <type> $identifier
* @return <type>
*/
private function consume_identifier(&$identifier)
{
if (is_null($identifier) || $identifier == "")
{
return "";
}
if (is_numeric($identifier))
{
return " WHERE ".$this->config_map[self::DB_PRI_KEY_NAME]."=".$identifier;
}
if (is_string($identifier))
{
return " WHERE $identifier";
}
if (!is_array($identifier))
{
throw new Exception("invalid identifier type");
}
ksort($identifier);
reset($identifier);
$search = "";
if (is_numeric(current($identifier)))
{
// if the first value is a number, then we can deduce
// that all of the values are ids of the records this
// model is manipulating. so, we just get the the
// id column name for the table and set each one to the
// value, and or all of them together
foreach($identifier as $val)
{
if (is_numeric($val))
{
if ($search != "")
{
$search .= " || ";
}
$search .= $this->config_map[self::DB_PRI_KEY_NAME]."=".$val;
}
}
}
else
{
// go through each value and build the where clause of the query
foreach($identifier as $val)
{
// check for the type the value is
if (is_array($val))
{
// check to make sure that all of the required keys are set
if (!isset($val[self::ID_KEY]))
{
throw new Exception(
"invalid array identifier: key not set");
}
if (!isset($val[self::ID_SIGN]))
{
throw new Exception(
"invalid array identifier: sign not set");
}
if (!isset($val[self::ID_VAL]))
{
throw new Exception(
"invalid array identifier: val not set");
}
// check to see if 'func' is set... if it isn't, then
// we escape the string and wrap it around quotes,
// if it is set, then let it string go unaffected
$value = "";
if (isset($val[self::ID_ESCAPE]))
{
if ($val[self::ID_ESCAPE])
{
$value = "'".$this->conn->escape_string(
$val[self::ID_VAL])."'";
}
else
{
$value = $val[self::ID_VAL];
}
}
else
{
$value = "'".$this->conn->escape_string($val[self::ID_VAL])."'";
}
// include this into the search
$search .= $val[self::ID_KEY]." ".$val[self::ID_SIGN]." ".$value;
}
else if (is_string($val))
{
$search .= " $val ";
}
else
{
throw new Exception("invalid array identifier");
}
//.........这里部分代码省略.........