本文整理汇总了PHP中JDatabaseQuery::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery::escape方法的具体用法?PHP JDatabaseQuery::escape怎么用?PHP JDatabaseQuery::escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseQuery
的用法示例。
在下文中一共展示了JDatabaseQuery::escape方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEscapeException
/**
* Tests the JDatabaseQuery::escape method for an expected exception.
*
* @return void
*
* @covers JDatabaseQuery::escape
* @expectedException RuntimeException
* @since 11.3
*/
public function testEscapeException()
{
// Override the internal database for testing.
$this->_instance->db = new stdClass;
$this->_instance->escape('foo');
}
示例2: toDatabase
/**
* Adds fields on this event to a query being prepared to go into the database
* @param JDatabaseQuery &$query Query being prepared. Modified in place.
*/
public function toDatabase(JDatabaseQuery &$query)
{
foreach ($this->dbmappings as $var => $dbField) {
if (isset($this->{$var})) {
$query->set($dbField . " = '" . $query->escape($this->{$var}) . "'");
}
}
}
示例3: sqlValues
/**
* Converts an array of values to a string that can be used in SQL to set
* the according values in a query.
*
* @param array $data Values that should be processed.
* @param JDatabaseQuery $q Optional query object for escaping.
*
* @return array
*/
public static function sqlValues($data, $q = null)
{
$output = array();
foreach ($data as $key => $value) {
if ($value !== null) {
if ($q) {
$value = $q->escape($value);
}
$output[] = $key . ' = "' . $value . '"';
}
}
return $output;
}
示例4: toDatabase
public function toDatabase(JDatabaseQuery &$query)
{
$query->set("on_date = '" . $query->escape(strftime("%Y-%m-%d", $this->start)) . "'");
if (date("Hi", $this->start) != 0) {
$query->set("starttime = '" . $query->escape(strftime("%H:%M", $this->start)) . "'");
} else {
$query->set("starttime = NULL");
}
if (!empty($this->end)) {
$query->set("endtime = '" . $query->escape(strftime("%H:%M", $this->end)) . "'");
} else {
$query->set("endtime = NULL");
}
if (!empty($this->newMemberStart)) {
$query->set("newmemberstart = '" . $query->escape(strftime("%H:%M", $this->newMemberStart)) . "'");
} else {
$query->set("newmemberstart = NULL");
}
if (!empty($this->newMemberEnd)) {
$query->set("newmemberend = '" . $query->escape(strftime("%H:%M", $this->newMemberEnd)) . "'");
} else {
$query->set("newmemberend = NULL");
}
$query->set("version = " . $this->alterations->version);
$query->set("lastmodified = '" . $query->escape($this->alterations->lastModified) . "'");
$query->set('detailsaltered = ' . (int) $this->alterations->details);
$query->set('cancelled = ' . (int) $this->alterations->cancelled);
$query->set('placetimealtered = ' . (int) $this->alterations->placeTime);
$query->set('organiseraltered = ' . (int) $this->alterations->organiser);
$query->set('datealtered = ' . (int) $this->alterations->date);
if (!empty($this->latLng)) {
$query->set("latitude = " . $this->latLng->lat);
$query->set("longitude = " . $this->latLng->lng);
} else {
$query->set("latitude = NULL");
$query->set("longitude = NULL");
}
parent::toDatabase($query);
}
示例5: testEscapeException
/**
* Tests the JDatabaseQuery::escape method for an expected exception.
*
* @return void
*
* @expectedException RuntimeException
* @since 11.3
*/
public function testEscapeException()
{
// Override the internal database for testing.
TestReflection::setValue($this->_instance, 'db', new stdClass());
$this->_instance->escape('foo');
}