Wednesday, April 11, 2012

Re: CakePHP, Linux and MS Sql Server

in the $mssql it's  'database' => 'database' - but thats not that important.

we also tried the SqlSrv datasource from the Datasources plugin (cakephp github)
But this seems to use the sqlsrv extension which is also not available on our linux setup



Am Mittwoch, 11. April 2012 21:29:24 UTC+2 schrieb euromark:
We have been trying for hours getting a second datasource to work which connects to a MS Sql Server (2008) from linux.
On windows we have running the "pdo_sqlserv" extension. And with a few hours of trial and error and installation of different drivers we got it up and running.
We use the following datasource:

public $mssql = array(
'datasource' => 'Database/Sqlserver',
'host' => '192.168.0.2\SQLEXPRESS',
'login' => 'user',
'password' => 'pwd',
'database' => 'table',
);

On linux, though, we cannot get pdo_sqlserv to run (confirmed with phpinfo). Only mssql (for plain mssql where is no datasource for) or pdo_dblib.
The latter is supposed to be the eqivalent to the windows pdo_sqlserv but the datasource always errors with `datasource could not be created`.

What does work, though, is using this manuel statement:

            $dsn = 'dblib:dbname=database;host=192.168.0.2\sqlexpress';
            $user = 'user';
            $password = 'pwd';

            $dbh = new PDO($dsn, $user, $password);

            $stmt = $dbh->prepare("SELECT * FROM tablename");
            $stmt->execute();
            while ($row = $stmt->fetch()) {
                ...
            }

So the connection details seem to be right and the connection is establishable. 
Only the extension/module which our Sqlserver datasource is expeting is not really working.
We have to use this manual snippet which, of course, is incompatible to the rest of the model code (which uses the datasource for find(first) and find(all) queries).

note: that we replaced "sqlserv:" with "dblib:" here in order to get it to work.
So is there some special dblib datasource here for linux? Or what's going on?
thx

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: