Have been experiencing diffulty loading the models. This is a two part question. Is there a way to ramp up the verbosity of the errors. The model errors are very generic and don't give the same pinpoint accuracy we get just using PHP.
[Sun May 17 08:19:33.508702 2015] [:error] [pid 10568] [client XXXX.XXX.XXX.XXX:51994] PHP Fatal error: Uncaught exception 'Phalcon\\Mvc\\Model\\Exception' with message 'Model 'organisation' could not be loaded' in /var/www/xxxx/xxxx/index.php:12\nStack trace:\n#0 [internal function]: Phalcon\\Mvc\\Model\\Manager->load('organisation', true)\n#1 [internal function]: Phalcon\\Mvc\\Model\\Query->_prepareSelect()\n#2 [internal function]: Phalcon\\Mvc\\Model\\Query->parse()\n#3 [internal function]: Phalcon\\Mvc\\Model\\Query->execute(NULL, NULL)\n#4 /var/www/xxxx/xxxx/index.php(12): Phalcon\\Mvc\\Model\\Manager->executeQuery('SELECT * FROM o...')\n#5 [internal function]: {closure}()\n#6 /var/www/xxxx/xxxx/index.php(84): Phalcon\\Mvc\\Micro->handle()\n#7 {main}\n thrown in /var/www/xxxx/xxxx/index.php on line 12
The Model File content is:
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Query;
use Phalcon\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql;
$di = new FactoryDefault();
//Set up the database service
$di->set('db', function(){
return new PdoMysql(array(
"host" => "######",
"username" => "#####",
"password" => "######",
"dbname" => "######"
));
});
//Create and bind the DI to the application
$app = new Micro($di);
class organisation extends Model
{
public function getSource()
{
return 'sav1_organisations';
}
public function get_organisations($options = array())
{
$sql = "SELECT * ";
$sql .= "FROM sav1_organisations";
$query = new Query($sql, $this->getDI());
return $query->execute();
}
}
// Use Loader() to autoload our model
$loader = new Loader();
$loader->registerDirs(array(
__DIR__ . '/models/'
))->register();
called using:
//Retrieves all organisations
$app->get('/api/organisation', function() use ($app) {
$phql = "SELECT * FROM organisation ORDER BY orgName";
$organisation = $app->modelsManager->executeQuery($phql);
$data = array();
foreach ($organisation as $org) {
$data[] = array(
'id' => $org->id,
'name' => $org->orgName,
);
}
echo json_encode($data);
});
not sure where where the error is because the response from the server does not give enough detail (is it the password, namespace etc.)
Sorry to be a pain. Still learning. Hopefully this will be all for today :)