Exemplo n.º 1
0
 /**
  * Connects to the sql database and runs a sql query.
  *
  * @param  sql_query $sql   mysql query to be performed on the database.
  * @return object|boolean   returns a mysqli_result object if data is retrieved from the database
  *                          or boolean value if there is no data(true on success/false on failure).
  */
 protected static final function query($sql)
 {
     if (self::$conn == null) {
         self::$conn = new mysqli(self::$servername, self::$username, self::$password, self::$dbname);
         if (self::$conn->connect_error) {
             die("Connection failed: " . self::$conn->connect_error);
         }
     }
     return self::$conn->query($sql);
 }