本文整理汇总了PHP中JDatabaseDriver::query方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseDriver::query方法的具体用法?PHP JDatabaseDriver::query怎么用?PHP JDatabaseDriver::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseDriver
的用法示例。
在下文中一共展示了JDatabaseDriver::query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTable
protected function createTable()
{
$this->debug('createTable: Check if plugin table exists.');
// Create plugin table if doesn't exist
$query = "SHOW TABLES LIKE '{$this->db->getPrefix()}kunenadiscuss'";
$this->db->setQuery($query);
if (!$this->db->loadResult()) {
KunenaError::checkDatabaseError();
$query = "CREATE TABLE IF NOT EXISTS `#__kunenadiscuss`\n\t\t\t\t\t(`content_id` int(11) NOT NULL default '0',\n\t\t\t\t\t `thread_id` int(11) NOT NULL default '0',\n\t\t\t\t\t PRIMARY KEY (`content_id`)\n\t\t\t\t\t )";
$this->db->setQuery($query);
$this->db->query();
KunenaError::checkDatabaseError();
$this->debug("Created #__kunenadiscuss cross reference table.");
// Migrate data from old FireBoard discussbot if it exists
$query = "SHOW TABLES LIKE '{$this->db->getPrefix()}fb_discussbot'";
$this->db->setQuery($query);
if ($this->db->loadResult()) {
$query = "REPLACE INTO `#__kunenadiscuss`\n\t\t\t\t\tSELECT `content_id` , `thread_id`\n\t\t\t\t\tFROM `#__fb_discussbot`";
$this->db->setQuery($query);
$this->db->query();
KunenaError::checkDatabaseError();
$this->debug("Migrated old data.");
}
}
}
示例2: deleteByAttributes
/**
* Delete all rows by attributes
*
* @param array $conditions
*
* @return mixed
*/
public function deleteByAttributes(array $conditions)
{
$query = $this->db->getQuery(true);
$where = array();
foreach ($conditions as $ckey => $cvalue) {
$where[] = $this->quoteName($ckey) . ' = ' . (is_numeric($cvalue) ? intval($cvalue) : $this->quote($cvalue));
}
$query->delete($this->quoteName($this->tableName));
$query->where($where);
$this->db->setQuery($query);
return $this->db->query();
}
示例3: toggle
public function toggle($id, $property)
{
$this->db->setQuery('SELECT `' . $property . '` FROM #__acctexp_' . $this->table . ' WHERE `id` = ' . $id);
$newstate = $this->db->loadResult() ? 0 : 1;
if ($property == 'default') {
if (!$newstate) {
echo !$newstate;
return;
}
// Reset all other items
$this->db->setQuery('UPDATE #__acctexp_' . $this->table . ' SET `' . $property . '` = ' . ($newstate ? 0 : 1) . ' WHERE `id` != ' . $id);
$this->db->query();
}
$this->db->setQuery('UPDATE #__acctexp_' . $this->table . ' SET `' . $property . '` = ' . $newstate . ' WHERE `id` = ' . $id);
$this->db->query();
echo $newstate;
}
示例4: query
/**
* Execute the query
*
* @param string the query (optional, it will use the setQuery one otherwise)
* @return mixed A database resource if successful, FALSE if not.
*/
function query($sql = null)
{
if ($sql !== null) {
$this->setQuery($sql);
}
return $this->_db->query();
}