php-casbin / database-adapter

Database adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors when trying to connect postgresql DB

kuzkokov opened this issue · comments

Hi! I was going to use php-casbin together with this adapter, but I faced some troubles with it right at the beginning. I figure out how to fix them, but I don't think this is the right way to do it.

So, the first one: Fatal error: Class 'TechOne\Database\Connectors\PDO' not found, when trying to use Postgres connector. It appears that there is no use PDO; in techone/database/src/Connectors/Pgsql.php, though it is in techone/database/src/Connectors/Connector.php.

The second one is sql for creating the casbin table (casbin/database-adapter/src/Adapter.php, initTable function). Postgre was throwing syntax errors, so I had to change it on this:

CREATE TABLE IF NOT EXISTS $this->casbinRuleTableName (
  id bigserial NOT NULL,
  ptype varchar(255) NOT NULL,
  v0 varchar(255) DEFAULT NULL,
  v1 varchar(255) DEFAULT NULL,
  v2 varchar(255) DEFAULT NULL,
  v3 varchar(255) DEFAULT NULL,
  v4 varchar(255) DEFAULT NULL,
  v5 varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
);

I hope, this is helpfull and it's possible to fix that errors.

commented

This issue is fixed ,Please update to the latest version