cmoore4 / phalcon-rest

A Base project for APIs using the Phalcon framework
MIT License
218 stars 69 forks source link

Why I can't connect to mysql? #10

Open piavgh opened 9 years ago

piavgh commented 9 years ago

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 commented 9 years ago

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 commented 8 years ago

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 commented 7 years ago

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