本文整理汇总了PHP中JFactory::GetDBO方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::GetDBO方法的具体用法?PHP JFactory::GetDBO怎么用?PHP JFactory::GetDBO使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::GetDBO方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
protected function getData()
{
if ($this->element->sql) {
$db = JFactory::GetDBO();
$db->setQuery($this->element->sql);
$options = $db->loadObjectList();
return $options;
}
// Initialize variables.
$options = array();
foreach ($this->element->children() as $option) {
// Only add <option /> elements.
if ($option->getName() != 'option') {
continue;
}
$item = new stdClass();
$item->id = (string) $option['value'];
$item->display = JText::_(trim((string) $option));
$options[] = $item;
}
reset($options);
return $options;
}
示例2: load_db
public function load_db(){
global $wpdb;
if(class_exists('JFactory')){
$db =& JFactory::GetDBO();
if(isset($db->_resource))//J1.5
$this->db = new Guardian($db->_resource);
else//J1.6
$this->db = new Guardian($db->getConnection());
}
else if(!empty($wpdb) && isset($wpdb->dbh)){
$this->db = new Guardian($wpdb->dbh);
}
else{
$this->load_db_settings();
if(!empty($this->db_database) && !empty($this->db_host) && !empty($this->db_password) && !empty($this->db_username)){
$this->db = new Guardian($this->db_host, $this->db_username, $this->db_password, $this->db_database);
}
}
}