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

Why I can't connect to mysql? #10

Open
piavgh opened this issue Feb 27, 2015 · 3 comments
Open

Why I can't connect to mysql? #10

piavgh opened this issue Feb 27, 2015 · 3 comments

Comments

@piavgh
Copy link

piavgh commented Feb 27, 2015

Hi everyone, I've used Phalcon micro for a couple of months, and now I want to switch to something more RESTful, and I found this repo https://github.com/cmoore4/phalcon-rest

  1. I've declared database parameters in config.ini

    [database]
    adapter  = Mysql
    host     = localhost
    username = test
    password = test
    name     = test
  2. I've set the di to connect to db

    $di->set('db', function() use ($config) {
    $dbclass = 'Phalcon\Db\Adapter\Pdo\\' . $config->database->adapter;
    return new $dbclass(array(
        "host"     => $config->database->host,
        "username" => $config->database->username,
        "password" => $config->database->password,
        "dbname"   => $config->database->name
    ));
    });
  3. Class Princesses.php in is models folder

  4. When I tried to add this line

    $princesses = Princesses::find();
    in the ExampleController.php, I got the blank page when going to host/v1/example. When I removed that line, everything is fine.

What is the problem here?

Thank you very much. Any help is appreciated!

@dmytrome
Copy link

In model directory file with class has name Princess.php, but class has name Princesses:
...
use \PhalconRest\Exceptions\HTTPException;

class Princesses extends \Phalcon\Mvc\Model{
...
Rename class to Princess and check all references to this class in code.

@mosiera98
Copy link

hi
please describ how to get data from mysql in this project
i want to select data from my mysql db

can you help me????

@kevinzie
Copy link

can u help me and future user? i got same error.

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

4 participants