I'm trying to use Apicli to make a script that runs from command line.
This is my testing code (the script is in page/command)
include '../../atk4/loader.php';
$api=new ApiCLI('reportes');
$api->addLocation('atk4-addons',array(
'php'=>array(
'mvc',
'misc/lib',
)))->setParent($api->pathfinder->base_location);
$api->dbConnect();
$db = $this->api->db->dsql()
->table('test t')
->do_getAssoc();
The output of this is
PHP Fatal error: Uncaught exception 'ExceptionNotConfigured' with message 'You must specify $config['dsn'] in your config.php' in /var/www/ossec/atk4/lib/ApiCLI.php:238
Stack trace:
#0 /var/www/ossec/atk4/lib/ApiCLI.php(276): ApiCLI->getConfig('dsn')
#1 /var/www/ossec/page/crons/reportes.php(13): ApiCLI->dbConnect()
#2 {main}
thrown in /var/www/ossec/atk4/lib/ApiCLI.php on line 238
this do not reads config-default.php ? I've add
$config['dsn']='mysql://user:pass@localhost/test';
But it doesn't works.
Thanks all
looking at ApiCli.php and seen the db definition, I've passed the parameters via the method
$api->dbConnect('mysql://user:pass@localhost/test');
And now It's working fine.
Regards Alejandro