| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * User: DFiNE
- * Date: 20/01/2019
- * Time: 13.05
- */
-
- class DBclass
- {
- var $classQuery;
- var $link;
-
- var $errno = '';
- var $error = '';
-
- // Connects to the database
- function __construct()
- {
-
- // Get the main settings from the array we just loaded
- $host = Config::$mysql_host;
- $name = Config::$mysql_db;
- $user = Config::$mysql_user;
- $pass = Config::$mysql_pass;
-
- // Connect to the database
- $this->link = new mysqli( $host , $user , $pass , $name );
- $this->link->set_charset("utf8"); // Set charset to UTF-8, always!
- }
-
- // Executes a database query
- function query( $query )
- {
- $this->classQuery = $query;
- return $this->link->query( $query );
- }
-
- function escapeString( $query )
- {
- return $this->link->escape_string( $query );
- }
-
- // Get the data return int result
- function numRows( $result )
- {
- return $result->num_rows;
- }
-
- function lastInsertedID()
- {
- return $this->link->insert_id;
- }
-
- // Get query using assoc method
- function fetchAssoc( $result )
- {
- return $result->fetch_assoc();
- }
-
- // Gets array of query results
- function fetchArray( $result , $resultType = MYSQLI_ASSOC )
- {
- return $result->fetch_array( $resultType );
- }
-
- // Fetches all result rows as an associative array, a numeric array, or both
- function fetchAll( $result , $resultType = MYSQLI_ASSOC )
- {
- return $result->fetch_all( $resultType );
- }
-
- // Get a result row as an enumerated array
- function fetchRow( $result )
- {
- return $result->fetch_row();
- }
-
- // Free all MySQL result memory
- function freeResult( $result )
- {
- $this->link->free_result( $result );
- }
-
- //Closes the database connection
- function close()
- {
- $this->link->close();
- }
-
- function sql_error()
- {
- if( empty( $error ) )
- {
- $errno = $this->link->errno;
- $error = $this->link->error;
- }
- return $errno . ' : ' . $error;
- }
- }
|