File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -30,17 +30,23 @@ public function getSingleData($table=null, $query=[])
3030 }
3131 }
3232
33- public function postData ($ table =null , $ query =[])
33+ public function postData ($ table =null , $ query =[], $ on_conflict = null )
3434 {
35- if (!isset ($ table )) {
36- echo "Please provide your Supabase table name. " ;
37- } elseif (!isset ($ query )) {
38- echo "Please provide your data. " ;
39- } else {
40- $ path = "$ this ->url / $ table " ;
41- $ html = $ this ->grab ($ path , "POST " , json_encode ($ query ));
42- return $ html ;
43- }
35+ if (!isset ($ table )) {
36+ echo "Please provide your Supabase table name. " ;
37+ } elseif (!isset ($ query )) {
38+ echo "Please provide your data. " ;
39+ } else {
40+ // If $on_conflict is provided, append to the path
41+ if (!empty ($ on_conflict )) {
42+ $ path = "$ this ->url / $ table?on_conflict= $ on_conflict " ;
43+ } else {
44+ $ path = "$ this ->url / $ table " ;
45+ }
46+
47+ $ html = $ this ->grab ($ path , "POST " , json_encode ($ query ));
48+ return $ html ;
49+ }
4450 }
4551
4652 public function updateData ($ table =null , ?int $ id =null , $ query =[])
You can’t perform that action at this time.
0 commit comments