| @@ 44-70 (lines=27) @@ | ||
| 41 | * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password |
|
| 42 | * @return resource |
|
| 43 | */ |
|
| 44 | function __connect($connection) |
|
| 45 | { |
|
| 46 | // Attempt to connect |
|
| 47 | if($connection["db_port"]) |
|
| 48 | { |
|
| 49 | $result = @mysqli_connect($connection["db_hostname"] |
|
| 50 | , $connection["db_userid"] |
|
| 51 | , $connection["db_password"] |
|
| 52 | , $connection["db_database"] |
|
| 53 | , $connection["db_port"]); |
|
| 54 | } |
|
| 55 | else |
|
| 56 | { |
|
| 57 | $result = @mysqli_connect($connection["db_hostname"] |
|
| 58 | , $connection["db_userid"] |
|
| 59 | , $connection["db_password"] |
|
| 60 | , $connection["db_database"]); |
|
| 61 | } |
|
| 62 | $error = mysqli_connect_errno(); |
|
| 63 | if($error) |
|
| 64 | { |
|
| 65 | $this->setError($error, mysqli_connect_error()); |
|
| 66 | return; |
|
| 67 | } |
|
| 68 | mysqli_set_charset($result, 'utf8'); |
|
| 69 | return $result; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * DB disconnection |
|
| @@ 44-70 (lines=27) @@ | ||
| 41 | * @param array $connection connection's value is db_hostname, db_port, db_database, db_userid, db_password |
|
| 42 | * @return resource |
|
| 43 | */ |
|
| 44 | function __connect($connection) |
|
| 45 | { |
|
| 46 | // Attempt to connect |
|
| 47 | if($connection["db_port"]) |
|
| 48 | { |
|
| 49 | $result = @mysqli_connect($connection["db_hostname"] |
|
| 50 | , $connection["db_userid"] |
|
| 51 | , $connection["db_password"] |
|
| 52 | , $connection["db_database"] |
|
| 53 | , $connection["db_port"]); |
|
| 54 | } |
|
| 55 | else |
|
| 56 | { |
|
| 57 | $result = @mysqli_connect($connection["db_hostname"] |
|
| 58 | , $connection["db_userid"] |
|
| 59 | , $connection["db_password"] |
|
| 60 | , $connection["db_database"]); |
|
| 61 | } |
|
| 62 | $error = mysqli_connect_errno(); |
|
| 63 | if($error) |
|
| 64 | { |
|
| 65 | $this->setError($error, mysqli_connect_error()); |
|
| 66 | return; |
|
| 67 | } |
|
| 68 | mysqli_set_charset($result, 'utf8'); |
|
| 69 | return $result; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * DB disconnection |
|