<?php class User extends Model { // =========== // = Statics = // =========== protected static $table_name = 'USER'; // load all users from Db public static function getList() { $stm = parent::exec('USER_LIST'); return $stm->fetchAll(); } public static function getUserByID($id) { $stm = parent::exec('USER_BY_ID',array(':user_id' => $id)); return $stm->fetchAll(); } public static function updateUser($values) { $stm = parent::exec('USER_UPDATE',$values); return "User updated"; } public static function createUser($values) { $stm = parent::exec('USER_CREATE',$values); return "User created"; } public static function deleteUser($id) { $stm = parent::exec('USER_DELETE',array(':id' => $id)); return "User deleted"; } public static function getListWithLogin($login) { $stm = parent::exec('USER_GET_WITH_LOGIN',array(':login' => $login)); return $stm->fetchAll(); } public static function tryLogin($login) { $users = static::getListWithLogin($login); return $users[0]; } }