Skip to content

Commit

Permalink
feat: Added doctrine/dbal v4.0. (#7)
Browse files Browse the repository at this point in the history
* #6 Added doctrine/dbal v4.0.

* fix: Apply suggestions from code review

---------

Co-authored-by: Jon <[email protected]>
  • Loading branch information
tasselchof and leeqvip authored Jun 10, 2024
1 parent 935a7fb commit 0ef3ce0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"license": "Apache-2.0",
"require": {
"casbin/casbin": "^3.0",
"doctrine/dbal": "^2.9|^3.0"
"doctrine/dbal": "^2.9|^3.0|^4.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0",
Expand Down
5 changes: 3 additions & 2 deletions src/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function newAdapter($connection): Adapter
*/
public function initTable()
{
$sm = $this->connection->getSchemaManager();
$sm = method_exists($this->connection, "createSchemaManager") ? $sm = $this->connection->createSchemaManager() : $sm = $this->connection->getSchemaManager();
if (!$sm->tablesExist([$this->policyTableName])) {
$schema = new Schema();
$table = $schema->createTable($this->policyTableName);
Expand Down Expand Up @@ -147,7 +147,8 @@ public function savePolicyLine($pType, array $rule)
public function loadPolicy(Model $model): void
{
$queryBuilder = $this->connection->createQueryBuilder();
$stmt = $queryBuilder->select('p_type', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5')->from($this->policyTableName)->execute();
$query = $queryBuilder->select('p_type', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5')->from($this->policyTableName);
$stmt = method_exists($query, "executeQuery") ? $query->executeQuery() : $query->execute();

while ($row = $this->fetch($stmt)) {
$this->loadPolicyArray($this->filterRule($row), $model);
Expand Down

0 comments on commit 0ef3ce0

Please sign in to comment.