Exemplo n.º 1
0
 public function edit($user, $pass, $id)
 {
     $db = Database::getInstance('app');
     $result = $db->prepare("UPDATE users SET password = ?, username = ? WHERE id = ?");
     $result->execute([md5($pass), $user, $id]);
     return true;
 }
 public function dbUpdate($property, $dataType)
 {
     $db = \ShoppingCart\Core\Database::getInstance('app');
     //var_dump("call addColum(" . "'" .$property . "'" . ", " . "'" .  $dataType . "'" . ")");
     $result = $db->prepare("call addColum2(" . "'" . $property . "'" . ", " . "'" . $dataType . "'" . ")");
     if (!$result->execute()) {
         throw new \InvalidArgumentException("Invalid property definition!");
     }
 }
 public static function isAdminUser($id)
 {
     $db = Database::getInstance(DatabaseConfig::DB_INSTANCE_NAME);
     $result = $db->prepare("SELECT id FROM users u\n                                INNER JOIN users_roles r\n                                ON u.id = r.user_id\n                                WHERE r.role_id = (SELECT id FROM roles WHERE name = 'administrator') AND u.id = ?");
     $result->execute([$id]);
     if ($result->rowCount() > 0) {
         return true;
     }
     return false;
 }
 public function __construct()
 {
     $this->db = Database::getInstance(DatabaseConfig::DB_INSTANCE_NAME);
     $this->db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
 }