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

Error: SQLSTATE[08006] [7] invalid connection option "name" #474

Closed
dreamsxin opened this issue Mar 14, 2013 · 7 comments
Closed

Error: SQLSTATE[08006] [7] invalid connection option "name" #474

dreamsxin opened this issue Mar 14, 2013 · 7 comments

Comments

@dreamsxin
Copy link
Contributor

<?php

return new \Phalcon\Config(array(
        'database' => array(
                'adapter'  => 'Postgresql',
                'host'     => 'localhost',
                'username' => 'postgres',
                'password' => '123456',
                'name'     => 'wxservice',
        ),
        'application' => array(
                'controllersDir' => __DIR__ . '/../../app/controllers/',
                'modelsDir'      => __DIR__ . '/../../app/models/',
                'viewsDir'       => __DIR__ . '/../../app/views/',
                'pluginsDir'     => __DIR__ . '/../../app/plugins/',
                'libraryDir'     => __DIR__ . '/../../app/library/',
                'baseUri'        => '/',
        ),
        'models' => array(
                'metadata' => array(
                        'adapter' => 'Memory'
                )
        )
));
@nikolasha
Copy link

dbname

@phalcon
Copy link
Collaborator

phalcon commented Mar 14, 2013

It must be 'dbname' => 'wxservice',

@phalcon phalcon closed this as completed Mar 14, 2013
@dreamsxin
Copy link
Contributor Author

sorry, change 'name' to 'dbname' error still.
run:
phalcon model --name=users

display:
Error: SQLSTATE[08006] [7] invalid connection option "name"

run:
webtools.php?_url=/models/create

display:
PDOException: SQLSTATE[08006] [7] invalid connection option "name"
#0 [internal function]: PDO->__construct('pgsql:host=loca...', 'postgres', '123456', Array)
#1 [internal function]: Phalcon\Db\Adapter\Pdo->connect(Array)
#2 [internal function]: Phalcon\Db\Adapter\Pdo\Postgresql->connect(Array)
#3 /var/www/phalcon/phalcon-devtools/scripts/Phalcon/Builder/Model.php(171): Phalcon\Db\Adapter\Pdo->__construct(Array)
#4 /var/www/phalcon/phalcon-devtools/scripts/Phalcon/Web/Tools/controllers/ModelsController.php(79): Phalcon\Builder\Model->build()
#5 [internal function]: ModelsController->createAction()
#6 [internal function]: Phalcon\Dispatcher->dispatch()
#7 /var/www/phalcon/phalcon-devtools/scripts/Phalcon/Web/Tools.php(264): Phalcon\Mvc\Application->handle()
#8 /var/www/phalcon/test/public/webtools.php(31): Phalcon\Web\Tools::main('/var/www/phalco...')
#9 {main}

@phalcon
Copy link
Collaborator

phalcon commented Mar 15, 2013

Are you changing it on your config.php file?

@dreamsxin
Copy link
Contributor Author

I‘m sure, Only error occurred in use phalcon tools.

<?php

return new \Phalcon\Config(array(
    'database' => array(
        'adapter'  => 'Postgresql',
        'host'     => 'localhost',
        'username' => 'postgres',
        'password' => '123456',
        'dbname'     => 'wxservice',
    ),
    'application' => array(
        'apiDir'         => __DIR__ . '/../../app/api/',
        'controllersDir' => __DIR__ . '/../../app/controllers/',
        'modelsDir'      => __DIR__ . '/../../app/models/',
        'viewsDir'       => __DIR__ . '/../../app/views/',
        'pluginsDir'     => __DIR__ . '/../../app/plugins/',
        'libraryDir'     => __DIR__ . '/../../app/library/',
        'baseUri'        => '/',
    ),
    'models' => array(
        'metadata' => array(
            'adapter' => 'Memory'
        )
    )
));

And document has inconsistency:
URL:http://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Model.html
protected skipAttributesOnCreate ()

Sets a list of attributes that must be skipped from the generated INSERT statement

<?php

class Robots extends \Phalcon\Mvc\Model
{

   public function initialize()
   {
       $this->skipAttributesOnUpdate(array('created_at'));
   }

}

@dreamsxin
Copy link
Contributor Author

System:Ubuntu12.04
Installing phalcon from Git

@le51
Copy link

le51 commented Mar 19, 2013

be sure to call in the bootstrap file (index.php) your adapter the right way:

    $di->set('db', function() use ($config) {
        return new \Phalcon\Db\Adapter\Pdo\Postgresql(array(
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname
        ));
    });

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