Skip to content

Commit deba295

Browse files
committed
Merge pull request #220 from avbdr/master
readme updates
2 parents de2a617 + a204875 commit deba295

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

readme.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2323
To utilize this class, first import MysqliDb.php into your project, and require it.
2424

2525
```php
2626
require_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
2936
Simple 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

3446
Advanced 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.
4658
Reuse 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

5264
Its 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);
6779
if($id)
68-
echo 'user was created. Id='.$id;
80+
echo 'user was created. Id=' . $id;
6981
```
7082

7183
Insert 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");
139151
echo "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
192204
This method allows you to specify where parameters of the query.
205+
193206
WARNING: 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

195208
Regular == operator with variables:

0 commit comments

Comments
 (0)