Error accessing external database (started with Joomla 3.9.5)

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
ruraldev
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Fri Jun 30, 2006 5:57 pm

Error accessing external database (started with Joomla 3.9.5)

Post by ruraldev » Wed Apr 10, 2019 6:22 am

I have been getting a SQL errror since upgrading which I think is being caused by my code to get data from an external database. It worked fine until the upgrade.

The error is:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3

My SQL code is as follows:

Code: Select all

public static $db;
	
	public static function connect(){
		if(!self::$db){
			$config = new LanoilConfig();
			$option = array(); //prevent problems
			$option['driver']   = $config->dbdriver;    // Database driver name
			$option['host']     = $config->dbhost;    	// Database host name
			$option['user']     = $config->dbuser;      // User for database authentication
			$option['password'] = $config->dbpass;   	// Password for database authentication
			$option['database'] = $config->db;      	// Database name
			$option['prefix']   = $config->dbprefix;    // Database prefix (may be empty)
			 
			self::$db = JDatabaseDriver::getInstance($option);
		}
		return self::$db;
	}
	
	private function getDbo(){
		return self::connect();
	}
	
		    public function getprofile($mem){
		    $db = $this->getDbo();
		    $conditions = array(
			$db->quoteName('membership_number') . '=' . $mem
		    );
		    $query = $db->getQuery(true)
			->select(array('*'))
			->from('tbl_clients')
			->where($conditions);
		    $db->setQuery($query);
		    return $db->loadAssoc();
	}
Last edited by toivo on Wed Apr 10, 2019 6:35 am, edited 1 time in total.
Reason: mod note: moved to 3.x Coding

ruraldev
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Fri Jun 30, 2006 5:57 pm

Re: Error accessing external database (started with Joomla 3.9.5)

Post by ruraldev » Wed Apr 10, 2019 10:19 am

I've found the error is to do with Custom User Fields.

$customFields[0]->value

now seems to be

$customFields[0]->rawvalue

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 11034
Joined: Thu Feb 15, 2007 5:48 am
Location: Oxford, UK

Re: Error accessing external database (started with Joomla 3.9.5)

Post by toivo » Wed Apr 10, 2019 10:33 am

Posts and code examples normally stay at the forum after the issue has been resolved because some other users may benefit from the same solution in the future.
Toivo Talikka, Global Moderator
troubleshooting smtp and other articles http://talikka.com/joomla


Post Reply

Return to “Joomla! 3.x Coding”