Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //prototype crud sederhana
- class User {
- protected $table = 'user';
- public function read(){
- $sql = "select * from ". $this->table;
- //run sql code here
- echo "result of records";
- }
- public function create($name){
- $sql = "insert into ".$this->table." (name) values('".$name."')";
- //run the sql code here
- echo "create function";
- }
- public function update($id,$name){
- $sql = "update ".$this->table. " set name = '$name' where id=".$id;
- //run the sql code here
- echo "update record by id";
- }
- public function delete($id){
- $sql = "delete ".$this->table ." where id = ".$id;
- //run the sql code here
- echo "delete record by id";
- }
- }
- //example usage
- $user = new User();
- $user->create('rifaqu');
- $user->read();
- $user->update(1,'new name');
- $user->delete(1); //by id;
Advertisement
Add Comment
Please, Sign In to add comment