From 1f7b99ea2359d95b3ce93f308d72e45a547a6714 Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Sun, 26 Apr 2015 04:09:51 +0000 Subject: [PATCH 1/2] Added installation via composer into readme --- readme.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 21d0cd96..df6b5853 100644 --- a/readme.md +++ b/readme.md @@ -19,17 +19,29 @@ MysqliDb -- Simple MySQLi wrapper with prepared statements **[Helper Functions](#helper-commands)** **[Transaction Helpers](#transaction-helpers)** -### Initialization +### Installation To utilize this class, first import MysqliDb.php into your project, and require it. ```php require_once ('MysqliDb.php'); ``` +### Installation with composer +It is also possible to install library via composer +``` +composer require joshcam/mysqli-database-class:dev-master +``` + +### Initialization Simple initialization with utf8 charset by default: ```php $db = new MysqliDb ('host', 'username', 'password', 'databaseName'); ``` +Or in case usage of the namespaces: +```php +$db = new \MysqliDb ('host', 'username', 'password', 'databaseName'); +``` + Advanced initialization. If no charset should be set charset, set it to null ```php From a204875d902bae0556952d19a6acf3936a4c1bab Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Sun, 26 Apr 2015 04:15:12 +0000 Subject: [PATCH 2/2] Couple typo fixed in readme --- readme.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index df6b5853..e7b06849 100644 --- a/readme.md +++ b/readme.md @@ -45,7 +45,7 @@ $db = new \MysqliDb ('host', 'username', 'password', 'databaseName'); Advanced initialization. If no charset should be set charset, set it to null ```php -$db = new Mysqlidb (Array ( +$db = new MysqliDb (Array ( 'host' => 'host', 'username' => 'username', 'password' => 'password', @@ -58,7 +58,7 @@ port and charset params are optional. Reuse already connected mysqli: ```php $mysqli = new mysqli ('host', 'username', 'password', 'databaseName'); -$db = new Mysqlidb ($mysqli); +$db = new MysqliDb ($mysqli); ``` Its also possible to set a table prefix: @@ -74,15 +74,15 @@ Simple example $data = Array ("login" => "admin", "firstName" => "John", "lastName" => 'Doe' -) -$id = $db->insert('users', $data); +); +$id = $db->insert ('users', $data); if($id) - echo 'user was created. Id='.$id; + echo 'user was created. Id=' . $id; ``` Insert with functions use ```php -$data = Array( +$data = Array ( 'login' => 'admin', 'active' => true, 'firstName' => 'John', @@ -151,7 +151,7 @@ $stats = $db->getOne ("users", "sum(id), count(*) as cnt"); echo "total ".$stats['cnt']. "users found"; ``` -or select one column or function result +or select one column value or function result ```php $count = $db->getValue ("users", "count(*)"); @@ -202,6 +202,7 @@ print_r ($results); // contains Array of returned rows ### Where Method This method allows you to specify where parameters of the query. + 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. Regular == operator with variables: