本文整理汇总了PHP中JDatabaseQuery::set方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery::set方法的具体用法?PHP JDatabaseQuery::set怎么用?PHP JDatabaseQuery::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseQuery
的用法示例。
在下文中一共展示了JDatabaseQuery::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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}) . "'");
}
}
}
示例2: reschedule
/**
* Reschedule the plugin for next run, and republish
*
*
* @return void
*/
protected function reschedule()
{
$now = JFactory::getDate();
$now = $now->toUnix();
$new = JFactory::getDate($this->row->nextrun);
$tmp = $new->toUnix();
switch ($this->row->unit) {
case 'second':
$inc = 1;
break;
case 'minute':
$inc = 60;
break;
case 'hour':
$inc = 60 * 60;
break;
default:
case 'day':
$inc = 60 * 60 * 24;
break;
}
while ($tmp + $inc * $this->row->frequency < $now) {
$tmp = $tmp + $inc * $this->row->frequency;
}
// Mark them as being run
$nextRun = JFactory::getDate($tmp);
$this->query->clear();
$this->query->update('#__{package}_cron');
$this->query->set('lastrun = ' . $this->db->quote($nextRun->toSql()));
if ($this->pluginModel->shouldReschedule() && $this->pluginModel->doRunGating()) {
$this->query->set("published = '1'");
}
if (!$this->pluginModel->shouldReschedule()) {
$this->query->set("published = '0'");
$this->log->message .= "\nPlugin has unpublished itself";
}
$this->query->where('id = ' . $this->row->id);
$this->db->setQuery($this->query);
$this->db->execute();
}
示例3: testSet
/**
* Tests the JDatabaseQuery::set method.
*
* @return void
*
* @covers JDatabaseQuery::set
* @since 11.3
*/
public function testSet()
{
$this->assertThat($this->_instance->set('foo = 1'), $this->identicalTo($this->_instance), 'Tests chaining.');
$this->assertEquals('SET foo = 1', trim(TestReflection::getValue($this->_instance, 'set')), 'Tests set with a string.');
$this->_instance->set('bar = 2');
$this->assertEquals("SET foo = 1\n\t, bar = 2", trim(TestReflection::getValue($this->_instance, 'set')), 'Tests appending with set().');
// Clear the set.
TestReflection::setValue($this->_instance, 'set', null);
$this->_instance->set(array('foo = 1', 'bar = 2'));
$this->assertEquals("SET foo = 1\n\t, bar = 2", trim(TestReflection::getValue($this->_instance, 'set')), 'Tests set with an array.');
// Clear the set.
TestReflection::setValue($this->_instance, 'set', null);
$this->_instance->set(array('foo = 1', 'bar = 2'), ';');
$this->assertEquals("SET foo = 1\n\t; bar = 2", trim(TestReflection::getValue($this->_instance, 'set')), 'Tests set with an array and glue.');
}
示例4: testSet
/**
* Tests the JDatabaseQuery::set method.
*
* @return void
*
* @covers JDatabaseQuery::set
* @since 11.3
*/
public function testSet()
{
$this->assertThat($this->_instance->set('foo = 1'), $this->identicalTo($this->_instance), 'Tests chaining.');
$this->assertThat(trim($this->_instance->set), $this->identicalTo('SET foo = 1'), 'Tests set with a string.');
$this->_instance->set('bar = 2');
$this->assertEquals("SET foo = 1" . PHP_EOL . "\t, bar = 2", trim($this->_instance->set), 'Tests appending with set().');
// Clear the set.
$this->_instance->set = null;
$this->_instance->set(array('foo = 1', 'bar = 2'));
$this->assertThat(trim($this->_instance->set), $this->identicalTo("SET foo = 1" . PHP_EOL . "\t, bar = 2"), 'Tests set with an array.');
// Clear the set.
$this->_instance->set = null;
$this->_instance->set(array('foo = 1', 'bar = 2'), ';');
$this->assertThat(trim($this->_instance->set), $this->identicalTo("SET foo = 1" . PHP_EOL . "\t; bar = 2"), 'Tests set with an array and glue.');
}
示例5: 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);
}