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

Database connection can't use persistent option #10484

Closed
ucando opened this issue Jun 7, 2015 · 3 comments
Closed

Database connection can't use persistent option #10484

ucando opened this issue Jun 7, 2015 · 3 comments

Comments

@ucando
Copy link

ucando commented Jun 7, 2015

I use postgresql, and I follow the phalcon's documents to set the persistent option, the code below

$db = new DbAdapter([
    "host" => $config->database->host,
    "port" => $config->database->port,
    "username" => $config->database->username,
    "password" => $config->database->password,
    "dbname" => $config->database->dbname,
    "persistent" => true
  ]);

It cause fatal error: SQLSTATE[08006] [7] invalid connection option "persistent". I must change my code like this:

$db = new DbAdapter([
    "host" => $config->database->host,
    "port" => $config->database->port,
    "username" => $config->database->username,
    "password" => $config->database->password,
    "dbname" => $config->database->dbname,
    "options" => [
        PDO::ATTR_PERSISTENT => true
      ]
  ]);

and the code can work.

is it a bug? or just the document is wrong?

@pauliuspetronis
Copy link
Contributor

I think it's a small bug :)

I think this block has to be before fetch dnsAttributes and unset descriptor["persistent"]. Otherwise persistent variable is joined to dsnAttributes and PostgreSql throw error about it.

@andresgutierrez
Copy link
Sponsor Contributor

This is fixed in the 2.0.3 branch

@pauliuspetronis
Copy link
Contributor

I created pull request #10489. @andresgutierrez - your fix did not resolve this problem. Because persistent is included in to dnsAttributes.

andresgutierrez added a commit that referenced this issue Jun 8, 2015
@phalcon phalcon closed this as completed in 2f86624 Jun 9, 2015
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

3 participants