/** * 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'); }
/** * 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}) . "'"); } } }
/** * 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; }
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); }
/** * 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'); }