I am trying to fetch data from a remote MSSQL Server. I am using WampServer on Windows 7 64bit Professional. My connection string is as follows:
$pdo = new PDO('sqlsrv:Server='.$host.';Database=' . $db, $user, $pass,
array(
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
I can successfully connect from my local computer and execute queries with this connection. Then I have uploaded my source to server which runs on Ubuntu 14.04 TLS. I got 0-no driver-found error. After that I have searched that this connection string is invalid for Ubuntu. I have updated it to
$pdo = new PDO('odbc:Driver=freetds; Server=1.2.3.4; Port=1433; Database=myDB; UID=myUser; PWD=myPass;');
After a few configuration, I could have succeeded to connect to the database with no error. But after querying then I try to use PDO's fetchAll()
method I get the following error:
PHP Fatal error: Call to a member function fetchAll() on a non-object
The code is the same with I always use. I think this is because of connection. But I do not know what to do next?
EDIT:
I can run this script on my local computer with no error. But it does not work on Ubuntu.