I'm trying to learn PHP Object Oriented, however I'm having trouble finding an example. Can someone show a simple example of the crud case below:
- A class in php, for example, user, in this class has methods that return the user by id.
-
All users return.
-
inserts the user.
-
update the user.
-
delete the user.
I also wanted to know how I can call this methods.
In case I will use ajax then I will have to use a php file instantiated the class object.
I apologize for the naivety, but I believe that here I will have the best examples and support in the doubts.
If anyone knows / has any material relevant to this, I would also appreciate it.
What I did:
<?php
class Listas{
public $guid;
public $eguid;
public $concluida;
public $titulo;
public $descricao;
public $datecreate;
function listarListas($db){
$result = $db->select('cad_listaconf');
$res = array();
$res = $db->getResult();
return $res;
}
function inserirLista($eguid, $titulo, $descricao, $datecreate, $db){
if ($query = $db->insert('cad_listaconf', array('eguid'=>$eguid, 'titulo'=>$titulo, 'descricao'=>$descricao, 'datacreate'=>$datecreate))){
return 1;
} else {
return 0;
}
}
}
?>