Skip to content

Commit e7be677

Browse files
committed
Updated casbin to 1.x .
1 parent 5fa40e0 commit e7be677

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

composer.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
{
2-
"name": "casbin/database-adapter",
3-
"keywords": ["casbin", "database", "casbin-adapter"],
4-
"description": "Database adapter for php-casbin. ",
5-
"authors": [
6-
{
7-
"name": "TechLee",
8-
"email": "[email protected]"
9-
}
10-
],
11-
"license": "Apache-2.0",
12-
"require": {
13-
"casbin/casbin": ">=0.2",
14-
"techone/database": ">=0.2.0"
15-
},
16-
"require-dev": {
17-
"phpunit/phpunit": "~5.7|~6.0",
18-
"php-coveralls/php-coveralls": "^2.1"
19-
},
20-
"autoload": {
21-
"psr-4": {
22-
"CasbinAdapter\\Database\\": "src/"
23-
}
24-
},
25-
"autoload-dev": {
26-
"psr-4": {
27-
"Tests\\": "tests/"
28-
}
29-
}
30-
}
1+
{
2+
"name": "casbin/database-adapter",
3+
"keywords": ["casbin", "database", "casbin-adapter"],
4+
"description": "Database adapter for php-casbin. ",
5+
"authors": [
6+
{
7+
"name": "TechLee",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"license": "Apache-2.0",
12+
"require": {
13+
"casbin/casbin": "~1.0",
14+
"techone/database": ">=0.2.0"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "~5.7|~6.0|~7.0",
18+
"php-coveralls/php-coveralls": "^2.1"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"CasbinAdapter\\Database\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"Tests\\": "tests/"
28+
}
29+
}
30+
}

src/Adapter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ public function savePolicyLine($ptype, array $rule)
5858

5959
public function loadPolicy($model)
6060
{
61-
$rows = $this->connection->query('SELECT * FROM '.$this->casbinRuleTableName.'');
61+
$rows = $this->connection->query('SELECT ptype, v0, v1, v2, v3, v4, v5 FROM '.$this->casbinRuleTableName.'');
6262

6363
foreach ($rows as $row) {
64-
$line = implode(', ', array_slice(array_values($row), 1));
64+
$line = implode(', ', array_filter($row, function ($val) {
65+
return '' != $val && !is_null($val);
66+
}));
6567
$this->loadPolicyLine(trim($line), $model);
6668
}
6769
}

tests/casbin.db

12 KB
Binary file not shown.

0 commit comments

Comments
 (0)