steinhaug/mysqli

Mysqli Abstraction Layer

v1.6.5 2024-06-10 11:38 UTC

This package is auto-updated.

Last update: 2024-06-10 11:39:27 UTC


README

Mysqli Abstraction Layer v1.6.1

Description: Mainly for development and logging of queries, but now that the class is up and running future releases should be expected to do the heavy lifting of queries and iteration.

Maintained by: @steinhaug

Version history

v1.6.4

  • Bugfix, error_number has to be int

v1.6.4

  • buddy() updated, has prepared output aswell. echo $mysqli->buddy('table','insert','prepared');
  • parse_col_type, added prepared for type

v1.6.3

  • Added mode for ->result('assoc') without using second parameter.

v1.6.2

  • Updated for PHP 8.1

Install by composer

To install the library use composer:

composer require steinhaug/mysqli

Init

We want this to be a replacement for the existing $mysqli function in PHP so initialize your DB connection, using credentials from credentials.php in project.

$mysqli = Mysqli2::getInstance($mysql_host, $mysql_port, $mysql_user, $mysql_password, $mysql_database);

if ($mysqli->connect_errno) {
    echo 'Failed to connect to MySQL: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error;
}

if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    exit();
}