Hi,
I am trying to use the Phalcon database adapter to keep a history of all actions in a database.
My code doesn't work and I don't understand why.
In the file services.php, I have the following code:
$di->setShared('db', function () use ($config) { return new Mysql([ 'host' => $config->db->host, 'username' => $config->db->username, 'password' => $config->db->password, 'dbname' => $config->db->dbname ]); }); $di->setShared('logger', function () use ($config) { $db = new Mysql([ 'host' => $config->db->host, 'username' => $config->db->username, 'password' => $config->db->password, 'dbname' => $config->db->dbname ]); $log = new DbLogger('errors', [ 'db' => $db, 'table' => 'logs' ]); return $log; });
In my controller, I have the following code:
public function indexAction() { $this->logger->info("test"); }
And the following table is used to store the logs:
CREATE TABLE `logs` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(32) DEFAULT NULL, `type` int(3) NOT NULL, `content` text, `created_at` int(18) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
I have included all the adapters required (Phalcon\Logger\Adapter\Database, Phalcon\Db\Adapter\Pdo\Mysql, etc..).
Do you have an idea ?