@@ -29,7 +29,7 @@ class Adapter implements AdapterContract, FilteredAdapterContract, BatchAdapterC
2929
3030    protected  $ connection
3131
32-     public  $ casbinRuleTableName 'casbin_rule ' ;
32+     public  $ policyTableName 'casbin_rule ' ;
3333
3434    public  $ rows
3535
@@ -38,6 +38,11 @@ public function __construct(array $config)
3838        $ this config  = $ config
3939        $ this filtered  = false ;
4040        $ this connection  = (new  Manager ($ configgetConnection ();
41+         
42+         if  (isset ($ config'policy_table_name ' ]) && !is_null ($ config'policy_table_name ' ])) {
43+             $ this policyTableName  = $ config'policy_table_name ' ];
44+         }
45+ 
4146        $ this initTable ();
4247    }
4348
@@ -89,7 +94,7 @@ public static function newAdapter(array $config)
8994    public  function  initTable ()
9095    {
9196        $ sqlfile_get_contents (__DIR__ .'/../migrations/ ' .$ this config ['type ' ].'.sql ' );
92-         $ sqlstr_replace ('%table_name% ' , $ this casbinRuleTableName , $ sql
97+         $ sqlstr_replace ('%table_name% ' , $ this policyTableName , $ sql
9398        $ this connection ->execute ($ sql
9499    }
95100
@@ -104,7 +109,7 @@ public function savePolicyLine($ptype, array $rule)
104109
105110        $ namertrim (str_repeat ('?,  ' , count ($ col',  ' );
106111
107-         $ sql'INSERT INTO  ' .$ this casbinRuleTableName .'( ' .$ colStr') VALUES ( ' .$ name')  ' ;
112+         $ sql'INSERT INTO  ' .$ this policyTableName .'( ' .$ colStr') VALUES ( ' .$ name')  ' ;
108113
109114        $ this connection ->execute ($ sqlarray_values ($ col
110115    }
@@ -116,7 +121,7 @@ public function savePolicyLine($ptype, array $rule)
116121     */ 
117122    public  function  loadPolicy (Model $ modelvoid 
118123    {
119-         $ rows$ this connection ->query ('SELECT ptype, v0, v1, v2, v3, v4, v5 FROM  ' .$ this casbinRuleTableName .'' );
124+         $ rows$ this connection ->query ('SELECT ptype, v0, v1, v2, v3, v4, v5 FROM  ' .$ this policyTableName .'' );
120125
121126        foreach  ($ rowsas  $ row
122127            $ this loadPolicyArray ($ this filterRule ($ row$ model
@@ -158,7 +163,7 @@ public function addPolicy(string $sec, string $ptype, array $rule): void
158163
159164    public  function  addPolicies (string  $ secstring  $ ptypearray  $ rulesvoid 
160165    {
161-         $ table$ this casbinRuleTableName ;
166+         $ table$ this policyTableName ;
162167        $ columns'ptype ' , 'v0 ' , 'v1 ' , 'v2 ' , 'v3 ' , 'v4 ' , 'v5 ' ];
163168        $ values
164169        $ sets
@@ -206,7 +211,7 @@ public function removePolicy(string $sec, string $ptype, array $rule): void
206211            $ condition'v ' .strval ($ key' = : ' .'v ' .strval ($ key
207212        }
208213
209-         $ sql'DELETE FROM  ' .$ this casbinRuleTableName .' WHERE  ' .implode (' AND  ' , $ condition
214+         $ sql'DELETE FROM  ' .$ this policyTableName .' WHERE  ' .implode (' AND  ' , $ condition
210215
211216        $ this connection ->execute ($ sql$ where
212217    }
@@ -233,9 +238,9 @@ public function _removeFilteredPolicy(string $sec, string $ptype, int $fieldInde
233238            }
234239        }
235240
236-         $ deleteSql"DELETE FROM  {$ this casbinRuleTableName } WHERE  "  . implode (' AND  ' , $ condition
241+         $ deleteSql"DELETE FROM  {$ this policyTableName } WHERE  "  . implode (' AND  ' , $ condition
237242
238-         $ selectSql"SELECT * FROM  {$ this casbinRuleTableName } WHERE  "  . implode (' AND  ' , $ condition
243+         $ selectSql"SELECT * FROM  {$ this policyTableName } WHERE  "  . implode (' AND  ' , $ condition
239244
240245        $ oldP$ this connection ->query ($ selectSql$ where
241246        foreach  ($ oldPas  &$ item
@@ -275,7 +280,7 @@ public function removeFilteredPolicy(string $sec, string $ptype, int $fieldIndex
275280    public  function  loadFilteredPolicy (Model $ model$ filtervoid 
276281    {
277282        // the basic sql 
278-         $ sql'SELECT ptype, v0, v1, v2, v3, v4, v5 FROM  ' .$ this casbinRuleTableName  . ' WHERE  ' ;
283+         $ sql'SELECT ptype, v0, v1, v2, v3, v4, v5 FROM  ' .$ this policyTableName  . ' WHERE  ' ;
279284
280285        $ bind
281286
@@ -346,7 +351,7 @@ public function updatePolicy(string $sec, string $ptype, array $oldRule, array $
346351            $ update'v '  . strval ($ key' = : '  . $ placeholder
347352        }
348353
349-         $ sql"UPDATE  {$ this casbinRuleTableName } SET  "  . implode (',  ' , $ update" WHERE  "  . implode (' AND  ' , $ condition
354+         $ sql"UPDATE  {$ this policyTableName } SET  "  . implode (',  ' , $ update" WHERE  "  . implode (' AND  ' , $ condition
350355
351356        $ this connection ->execute ($ sqlarray_merge ($ updateValue$ where
352357    }
0 commit comments