joaoN1x / koolrest

PHP7 RESTfull easy quick solution based in JSON data exchange
6 stars 1 forks source link

how to use with Mysql database #1

Open rajurk2000 opened 7 years ago

rajurk2000 commented 7 years ago

hi,

whether i can use this PHP earlier version.

pls. explain more, as i wanted to use this code with Mysql data. like where i have to define userid/pw and mysql database.

joaoN1x commented 7 years ago

you can create a folder like /db/ where you create your singleton file for mysql, like /db/mysql.php

and this mysql.php would do all the mysql work for you as query, inserts and so on like class mydb { public static ....all your methods .... }

in doers/ folder, you just create your class doers/yourclass.php

and inside of it you extend or use directly your /db/mysql.php

... use db/mysql as dbms;

class your class { public $db; public function users_get() { dbms::query("select * from users"); }

}

the example of calculations uses a parent class inside this dummy folder called custom stuff (here I explain with a folder called db)

this is very flexible and already handles all the RESTfull stuff you would need