@@ -19,21 +19,33 @@ MysqliDb -- Simple MySQLi wrapper with prepared statements
1919** [ Helper Functions] ( #helper-commands ) **
2020** [ Transaction Helpers] ( #transaction-helpers ) **
2121
22- ### Initialization
22+ ### Installation
2323To utilize this class, first import MysqliDb.php into your project, and require it.
2424
2525``` php
2626require_once ('MysqliDb.php');
2727```
2828
29+ ### Installation with composer
30+ It is also possible to install library via composer
31+ ```
32+ composer require joshcam/mysqli-database-class:dev-master
33+ ```
34+
35+ ### Initialization
2936Simple initialization with utf8 charset by default:
3037``` php
3138$db = new MysqliDb ('host', 'username', 'password', 'databaseName');
3239```
40+ Or in case usage of the namespaces:
41+ ``` php
42+ $db = new \MysqliDb ('host', 'username', 'password', 'databaseName');
43+ ```
44+
3345
3446Advanced initialization. If no charset should be set charset, set it to null
3547``` php
36- $db = new Mysqlidb (Array (
48+ $db = new MysqliDb (Array (
3749 'host' => 'host',
3850 'username' => 'username',
3951 'password' => 'password',
@@ -46,7 +58,7 @@ port and charset params are optional.
4658Reuse already connected mysqli:
4759``` php
4860$mysqli = new mysqli ('host', 'username', 'password', 'databaseName');
49- $db = new Mysqlidb ($mysqli);
61+ $db = new MysqliDb ($mysqli);
5062```
5163
5264Its also possible to set a table prefix:
@@ -62,15 +74,15 @@ Simple example
6274$data = Array ("login" => "admin",
6375 "firstName" => "John",
6476 "lastName" => 'Doe'
65- )
66- $id = $db->insert('users', $data);
77+ );
78+ $id = $db->insert ('users', $data);
6779if($id)
68- echo 'user was created. Id='. $id;
80+ echo 'user was created. Id=' . $id;
6981```
7082
7183Insert with functions use
7284``` php
73- $data = Array(
85+ $data = Array (
7486 'login' => 'admin',
7587 'active' => true,
7688 'firstName' => 'John',
@@ -139,7 +151,7 @@ $stats = $db->getOne ("users", "sum(id), count(*) as cnt");
139151echo "total ".$stats['cnt']. "users found";
140152```
141153
142- or select one column or function result
154+ or select one column value or function result
143155
144156``` php
145157$count = $db->getValue ("users", "count(*)");
@@ -190,6 +202,7 @@ print_r ($results); // contains Array of returned rows
190202
191203### Where Method
192204This method allows you to specify where parameters of the query.
205+
193206WARNING: In order to use column to column comparisons only raw where conditions should be used as column name or functions cant be passed as a bind variable.
194207
195208Regular == operator with variables:
0 commit comments