<?php
class User extends BaseModule {
const users_table = "billing.users";
const accounts_table = "billing.accounts";
private $user_data;
private $user_accounts;
private $user_id;
public function __construct($id){
$this->user_id = $id;
//Инизиализируем БД $this->db = DB::getInstance();
parent::__construct();
$this->getUser();
$this->getAccounts();
}
public function getInfo(){
$result = $this->user_data;
$result['accounts'] = $this->user_accounts;
return $result;
}
public function addAccount($login,$password){
$this->db->insert(self::accounts_table,array("uid"=>$this->user_id,"login"=>$login,"password"=>md5($password)));
$this->getAccounts(); //Обновляем информацию
}
public function editUser($data){
/* всякие проверки */
$this->db->update(self::users_table,$data,array('id'=>$this->user_id));
$this->getUser(); //Обновляем информацию
}
private function getUser(){
return $this->user_data = $this->db->selectExOne(self::users_table,array("id"=>$this->user_id));
}
private function getAccounts(){
return $user_accounts = $this->db->selectEx(self::accounts_table,array("uid"=>$this->user_id));
}
}
?>