Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not work in Phlacon 3.0 and PHP 7 #5

Open
engsere opened this issue Aug 19, 2016 · 0 comments
Open

not work in Phlacon 3.0 and PHP 7 #5

engsere opened this issue Aug 19, 2016 · 0 comments

Comments

@engsere
Copy link

engsere commented Aug 19, 2016

I know that this lib is not support phalcon 3 and php7, but few small changes make it run.
I had to install php7.0-sybase and php-sybase

All changes are in Phalcon/Db/Adapter/Pdo/Sqlsrv.php

first: change declaration of connect function:

from: public function connect($descriptor = null)
to: public function connect(array $descriptor = null)

second: change connection via PDO
from:
$this->_pdo = new \PDO("sqlsrv:server={$descriptor['host']}:1433;database={$descriptor['dbname']}", $descriptor['username'], $descriptor['password'], $options);
to:
`$options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
$options[\PDO::ATTR_STRINGIFY_FETCHES] = true;

    $dsn= "dblib:host=".$descriptor['host'].":1433;dbname=".$descriptor['dbname'].";";
    $dbusername=$descriptor['username'];
    $dbpassword=$descriptor['password'];

    $this->_pdo = new \PDO($dsn,$dbusername,$dbpassword);
    $this->_pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);`

third and last: change declaration $dialectClass variable from:

$dialectClass = 'Phalcon\\Db\\Dialect\\' . $this->_dialectType;
to: $dialectClass = 'Phalcon\\Db\\Dialect\\' . ucfirst($this->_dialectType);

that changes help me and let use this lib co connect with mssql.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant