JOOMLA 2.5:从外部MSSQL数据库读取数据

时间:2015-07-22 20:55:06

标签: php sql-server joomla

在我的模型文件中,我尝试放置此代码,但不起作用。出了什么问题?

php_error.log中的

致命错误:在...中找不到“JDatabaseDriver”类

 protected function getListQuery()
    {

        //$db       = $this->getDbo();
        //$query    = $db->getQuery(true);

   $option = array(); 
    $option['driver']   = 'mssql';            
      $option['host']     = '10.10.10.9';    
        $option['user']     = 'lubo';       
          $option['password'] = 'lubo';   
            $option['database'] = 'vladka';      
              $option['prefix']   = '';             
                $db = JDatabaseDriver::getInstance( $option );
                 $query = $db->getQuery(true);

        $query->select('*');
        $query->from('dbo.vyrobky');


        return $query;
    }

1 个答案:

答案 0 :(得分:0)

正如@Cesar所指出的,Joomla 2.5中没有类JDatabaseDriver。您必须直接实例 JDatabaseSQLSrv

protected function getListQuery()
{
    $option = array(); 
    $option['host']     = '10.10.10.9';    
    $option['user']     = 'lubo';       
    $option['password'] = 'lubo';   
    $option['database'] = 'vladka';      
    $option['prefix']   = '';             
    $db = new JDatabaseDriverSQLSrv($option);
    $query = $db->getQuery(true);
    $query->select('*');
    $query->from('dbo.vyrobky');

    return $query;
}