Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("DoInclude.php");
- class user
- {
- private $id;
- private $data;
- public function __construct($user_id)
- {
- $this->id = $user_id;
- }
- public function set($detail = FALSE, $newData)
- {
- if ($detail) $this->data[$detail] = $newData;
- else $this->data = $newData;
- }
- public function get($detail = FALSE)
- {
- if ($detail) return $this->data[$detail];
- else return $this->data;
- }
- public function get_id()
- {
- return $this->id;
- }
- public function save_data()
- {
- if($this->id >= 1)
- {
- $stmt = getDBObject->prepare('UPDATE '.USER_TABLE.
- 'SET companyid=?, '.
- 'SET name=?, '.
- 'SET username=?, '.
- 'SET password=?, '.
- 'SET usertype=?, '.
- 'SET picturepath=?, '.
- 'SET tiboID=?, '.
- 'SET xpos=?, '.
- 'SET ypos=? '.
- 'WHERE ID=?');
- $stmt->bind_param('isssisiiii', $companyID, $name, $username, $pass, $userType, $picturepath, $tiboID, $xpos, $ypos, $this->id);
- $stmt->execute();
- $stmt->close();
- }
- else
- {
- $stmt = getDBObject->prepare('INSERT INTO '.USER_TABLE.' (companyid, name, username, password, usertype, picturepath, tiboID, xpos, ypos) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
- $stmt->bind_param('isssisiii', $this->data['companyid'], $this->data['name'], $this->data['username'], $this->data['password'], $this->data['usertype']
- $this->data['picturepath'], $this->data['tiboID'], $this->data['xpos'], $this->data['ypos'] );
- $stmt->execute();
- $stmt->close();
- $this->id = $stmt->insert_id;
- }
- }
- public function load_data()
- {
- if ($this->id >= 1)
- {
- $stmt = getDBObject->prepare('SELECT companyid, name, username, password, usertype, picturepath, tiboID, xpos, ypos FROM '.USER_TABLE.' WHERE id = ?');
- $stmt->bind_param('i', $this->id);
- $stmt->execute();
- $stmt->bind_result($companyID, $name, $username, $pass, $userType, $picturepath, $tiboID, $xpos, $ypos);
- if ($stmt->fetch())
- {
- $this->data = array(
- 'companyid' => $companyID,
- 'name' => $name,
- 'username' => $username,
- 'password' => $pass,
- 'usertype' => $userType,
- 'picturepath' => $picturepath,
- 'tiboID' => $tiboID,
- 'xpos' => $xpos,
- 'ypos' => $ypos
- );
- }
- $stmt->close();
- return TRUE;
- }
- else return FALSE;
- }
- }
Add Comment
Please, Sign In to add comment