Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("database.php");
- // User class
- class user {
- // Attributes
- public $uid,$ucognome,$unome,$uemail,$utel;
- private $db = null;
- function __construct() {
- $this->db = new Database();
- }
- // Insert user
- public function insert(){
- $sql = "INSERT INTO users (cognome,nome,email,telefono)
- VALUES('".$this->ucognome."', '".$this->unome."','".$this->uemail."'
- ,'".$this->utel."')";
- $this->db->run($sql);
- }
- // Delete user
- public function delete(){
- $sql = "DELETE FROM users WHERE id=". $this->uid;
- $this->db->run($sql);
- }
- // Update user
- public function update(){
- $sql = "UPDATE users SET cognome= '".$this->ucognome."',
- nome='".$this->unome."',
- email='".$this->uemail."',
- telefono='".$this->utel."'
- WHERE id ='".$this->uid."'";
- $this->db->run($sql);
- }
- // Display users
- public function display(){
- $temp_arr = array();
- $res = $this->db->run("SELECT * FROM users ORDER by cognome,nome ");
- $count=$this->db->rowCount();
- while($row = $this->db->fetchArray()) {
- $temp_arr[] =$row;
- }
- return $temp_arr;
- }
- // get id upload
- public function getid(){
- $nome = $this->unome;
- $cognome = $this->ucognome;
- $email = $this->uemail;
- $telefono = $this->utel;
- $sql = "SELECT id FROM users WHERE nome='$nome' and cognome='$cognome' and email='$email' and telefono='$telefono'";
- var_dump($this->db->prepare($sql)->execute());
- }
- // Get user by id (update)
- public function getUserById($uid){
- $temp_arr = array();
- $res = $this->db->run("SELECT * FROM users WHERE id=$uid");
- $userDetails = $this->db->fetchArray();
- return $userDetails;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement