Guest User

Untitled

a guest
May 20th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. <?php
  2. include_once("DoInclude.php");
  3.  
  4. class user
  5. {
  6. private $id;
  7. private $data;
  8.  
  9.  
  10. public function __construct($user_id)
  11. {
  12. $this->id = $user_id;
  13.  
  14. }
  15. public function set($detail = FALSE, $newData)
  16. {
  17. if ($detail) $this->data[$detail] = $newData;
  18. else $this->data = $newData;
  19. }
  20.  
  21.  
  22.  
  23. public function get($detail = FALSE)
  24. {
  25. if ($detail) return $this->data[$detail];
  26. else return $this->data;
  27. }
  28.  
  29. public function get_id()
  30. {
  31. return $this->id;
  32. }
  33.  
  34. public function save_data()
  35. {
  36. if($this->id >= 1)
  37. {
  38. $stmt = getDBObject->prepare('UPDATE '.USER_TABLE.
  39. 'SET companyid=?, '.
  40. 'SET name=?, '.
  41. 'SET username=?, '.
  42. 'SET password=?, '.
  43. 'SET usertype=?, '.
  44.  
  45. 'SET picturepath=?, '.
  46. 'SET tiboID=?, '.
  47. 'SET xpos=?, '.
  48. 'SET ypos=? '.
  49.  
  50. 'WHERE ID=?');
  51. $stmt->bind_param('isssisiiii', $companyID, $name, $username, $pass, $userType, $picturepath, $tiboID, $xpos, $ypos, $this->id);
  52. $stmt->execute();
  53. $stmt->close();
  54. }
  55. else
  56. {
  57. $stmt = getDBObject->prepare('INSERT INTO '.USER_TABLE.' (companyid, name, username, password, usertype, picturepath, tiboID, xpos, ypos) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
  58. $stmt->bind_param('isssisiii', $this->data['companyid'], $this->data['name'], $this->data['username'], $this->data['password'], $this->data['usertype']
  59. $this->data['picturepath'], $this->data['tiboID'], $this->data['xpos'], $this->data['ypos'] );
  60. $stmt->execute();
  61. $stmt->close();
  62. $this->id = $stmt->insert_id;
  63. }
  64.  
  65. }
  66.  
  67. public function load_data()
  68. {
  69. if ($this->id >= 1)
  70. {
  71. $stmt = getDBObject->prepare('SELECT companyid, name, username, password, usertype, picturepath, tiboID, xpos, ypos FROM '.USER_TABLE.' WHERE id = ?');
  72. $stmt->bind_param('i', $this->id);
  73. $stmt->execute();
  74. $stmt->bind_result($companyID, $name, $username, $pass, $userType, $picturepath, $tiboID, $xpos, $ypos);
  75. if ($stmt->fetch())
  76. {
  77. $this->data = array(
  78. 'companyid' => $companyID,
  79. 'name' => $name,
  80. 'username' => $username,
  81. 'password' => $pass,
  82. 'usertype' => $userType,
  83. 'picturepath' => $picturepath,
  84. 'tiboID' => $tiboID,
  85. 'xpos' => $xpos,
  86. 'ypos' => $ypos
  87. );
  88. }
  89. $stmt->close();
  90.  
  91. return TRUE;
  92. }
  93. else return FALSE;
  94. }
  95. }
Add Comment
Please, Sign In to add comment