Skip to content

Commit 2c9087d

Browse files
committed
more updates edits
1 parent c872dce commit 2c9087d

File tree

4 files changed

+76
-138
lines changed

4 files changed

+76
-138
lines changed

.gitattributes

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/.travis.yml export-ignore
66
/codecov.yml export-ignore
77
/examples export-ignore
8-
#/phpunit.xml.dist export-ignore
9-
#/tests export-ignore
10-
#/docs export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/tests export-ignore
10+
/docs export-ignore
11+
/tmp export-ignore

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"VARBIT",
2020
"VARCHAR",
2121
"autoload",
22+
"codecov",
2223
"ezmysqli",
2324
"ezpdo",
2425
"ezpgsql",
@@ -27,9 +28,12 @@
2728
"ezsqlsvr",
2829
"filebase",
2930
"isfile",
31+
"mysqli",
32+
"pgsql",
3033
"postgresql",
3134
"repo",
3235
"sqlserver",
36+
"sqlsrv",
3337
"tomssql",
3438
"tosql",
3539
"zerofill"

README.md

Lines changed: 25 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,43 @@
1-
**ezsql**
2-
=====
3-
[![Build Status](https://travis-ci.org/ezSQL/ezSQL.svg?branch=master)](https://travis-ci.org/ezSQL/ezSQL)
4-
[![Build status](https://ci.appveyor.com/api/projects/status/6s8oqnoxa2i5k04f/branch/master?svg=true)](https://ci.appveyor.com/project/jv2222/ezsql/branch/master)
5-
[![codecov](https://codecov.io/gh/ezSQL/ezSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/ezSQL/ezSQL)
6-
[![Maintainability](https://api.codeclimate.com/v1/badges/8db71512a019ab280a16/maintainability)](https://codeclimate.com/github/techno-express/ezSQL/maintainability)
7-
8-
Introduction
9-
10-
When working with databases most of the time you will want to do one of four types of basic operations.
11-
1. Perform a query such as Insert or Update (without results)
12-
2. Get a single variable from the database
13-
3. Get a single row from the database
14-
4. Get a list of results from the database
15-
16-
**ezsql** wraps up these four basic actions into four very easy to use functions.
17-
18-
bool $db->query(query)
19-
var $db->get_var(query)
20-
mixed $db->get_row(query)
21-
mixed $db->get_results(query)
1+
# **ezsql**
222

23-
With **ezsql** these four functions are all you will need 99.9% of the time. Of course there are also some other useful functions but we will get into those later.
24-
25-
Important Note: If you use **ezsql** inside a function you write, you will need to put global $db; at the top.
3+
[![Build Status](https://travis-ci.org/ezSQL/ezSQL.svg?branch=v4)](https://travis-ci.org/ezSQL/ezSQL)
4+
[![Build status](https://ci.appveyor.com/api/projects/status/6s8oqnoxa2i5k04f/branch/v4?svg=true)](https://ci.appveyor.com/project/jv2222/ezsql/branch/v4)
5+
[![codecov](https://codecov.io/gh/ezSQL/ezSQL/branch/v4/graph/badge.svg)](https://codecov.io/gh/ezSQL/ezSQL)
6+
[![Maintainability](https://api.codeclimate.com/v1/badges/8db71512a019ab280a16/maintainability)](https://codeclimate.com/github/techno-express/ezSQL/maintainability)
267

27-
Description
28-
------------
29-
Class to make it very easy to deal with database connections.
8+
***Class to make it very easy to deal with database connections.***
309

31-
· **ezsql** is a widget that makes it very fast and easy for you to use database(s) within your PHP scripts ( mysql/ postgreSQL / SQL Server/ SQLite3).
10+
This is [__version 4__](https://github.com/ezSQL/ezSQL/tree/v4) that has many modern programming practices in which will break users of version 3.
3211

33-
· It is one php file that you include at the top of your script. Then, instead of using standard php database functions listed in the php manual, you use a much smaller (and easier) set of **ezsql** functions.
12+
[__Version 3__](https://github.com/ezSQL/ezSQL/tree/v3) broke version 2.1.7 in one major way, it required *PHP 5.6*. Which drop mysql extension support, other than that, nothing as far using the library was changed, only additional features.
3413

35-
· It automatically caches query results and allows you to use easy to understand functions to manipulate and extract them without causing extra server overhead
14+
This library has an `Database` class, a combination of the [Factory](https://en.wikipedia.org/wiki/Factory_method_pattern) pattern with an [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) container hosting. The library is following many OOP principles, one in which, properties public access has been removed.
3615

37-
· It has excellent debug functions making it lightning-fast to see what’s going on in your SQL code
16+
- More Todo...
3817

39-
· Most **ezsql** functions can return results as Objects, Associative Arrays, or Numerical Arrays
18+
For an full overview see [documentation Wiki](https://github.com/ezSQL/ezSQL/WIKI.md), which is not completely finish.
4019

41-
· It can dramatically decrease development time and in most cases will streamline your code and make things run faster as well as making it very easy to debug and optimise your database queries.
20+
## Installation
4221

43-
· It is a small class and will not add very much overhead to your website.
44-
45-
Note: It is assumed that you are familiar with PHP, basic Database concepts and basic SQL constructs. Even if you are a complete beginner **ezsql** can help you once you have read and understood this tutorial.
22+
composer require ezsql/ezsql
4623

47-
Installation
48-
------
49-
`composer require ezsql/ezsql`
24+
## Usage
5025

51-
`require 'vendor/autoload.php';`
26+
```php
27+
require 'vendor/autoload.php';
5228

29+
// '****' is one of **mysqli**, **pgsql**, **sqlsrv**, **sqlite3**, or **Pdo**.
30+
use ezsql\Database;
5331

54-
**[Authors/Contributors](https://github.com/ezsql/ezsql/CONTRIBUTORS.md)**
55-
---
32+
$db = Database::initialize('****', [$dsn_path_user, $password, $database, $or, $other_settings], $optional_instance_tag);
5633

57-
Quick Examples..
34+
// Is same as:
35+
use ezsql\Config;
36+
use ezsql\Database\ez_****;
5837

59-
Note: In all these examples no other code is required other than including ez_sql.php
60-
61-
Example 1
62-
63-
// Select multiple records from the database and print them out..
64-
$users = $db->get_results("SELECT name, email FROM users");
65-
foreach ( $users as $user )
66-
{
67-
// Access data using object syntax
68-
echo $user->name;
69-
echo $user->email;
70-
}
71-
72-
Example 2
73-
74-
// Get one row from the database and print it out..
75-
$user = $db->get_row("SELECT name,email FROM users WHERE id = 2");
76-
echo $user->name;
77-
echo $user->email;
78-
79-
Example 3
80-
81-
// Get one variable from the database and print it out..
82-
$var = $db->get_var("SELECT count(*) FROM users");
83-
echo $var;
84-
85-
Example 4
86-
87-
// Insert into the database
38+
$setting = new Config('****', [$dsn_path_user, $password, $database, $or, $other_settings]);
8839

89-
```php
90-
$db->query("INSERT INTO users (id, name, email) VALUES (NULL,'justin','[email protected]')");
40+
$db = new ez_****($settings);
9141
```
92-
93-
Example 5
94-
95-
// Update the database
96-
$db->query("UPDATE users SET name = 'Justin' WHERE id = 2)");
97-
98-
Example 6
99-
100-
// Display last query and all associated results
101-
$db->debug();
102-
103-
Example 7
104-
105-
// Display the structure and contents of any result(s) .. or any variable
106-
$results = $db->get_results("SELECT name, email FROM users");
107-
$db->vardump($results);
108-
109-
Example 8
110-
111-
// Get 'one column' (based on column index) and print it out..
112-
$names = $db->get_col("SELECT name,email FROM users",0)
113-
foreach ( $names as $name )
114-
{
115-
echo $name;
116-
}
117-
118-
Example 9
119-
120-
// Same as above ‘but quicker’
121-
foreach ( $db->get_col("SELECT name,email FROM users",0) as $name )
122-
{
123-
echo $name;
124-
}
125-
126-
Example 10
127-
128-
// Map out the full schema of any given database and print it out..
129-
$db->select("my_database");
130-
foreach ( $db->get_col("SHOW TABLES",0) as $table_name )
131-
{
132-
$db->debug();
133-
$db->get_results("DESC $table_name");
134-
}
135-
$db->debug();
13642

43+
**For** **[Authors/Contributors](https://github.com/ezsql/ezsql/CONTRIBUTORS.md)**

WIKI.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,37 @@ Any articles referencing WordPress database engine is an good source of what kin
156156

157157
Version 4 of this library attempts to, beside all the additional features, _remove some bad coding styles_, _bring the library to modern coding practices of which_, _follow proper __OOP__ and be __PSR__ compliant_.
158158

159-
This version further break things introduced in version 3 that broke version 2.1.7. See [CHANGE LOG]()
159+
This version further break things introduced in version 3 that broke version 2.1.7. See [CHANGE LOG](https://github.com/ezsql/ezsql/CHANGELOG.md)
160160

161-
Installation
162-
____
161+
____Installation and Usage____
162+
---
163+
164+
Note: __****__ is one of '**mysqli**, **pgsql**, **sqlsrv**, **sqlite3**, or **Pdo**'.
165+
166+
Either: ***for version 3.x***
163167

164-
To install........
168+
composer require ezsql/ezsql=^3.1.0
169+
require 'vendor/autoload.php';
170+
---------
171+
// Manually download https://github.com/ezSQL/ezSQL/archive/v3.zip and extract.
172+
require 'ez_sql_loader.php';
173+
---------
174+
175+
$db = new ezSQL_****(user, password, database, or, other settings);
176+
177+
Or: ***for version 4.x***
178+
179+
// composer is required for version 4
180+
composer require ezsql/ezsql
181+
require 'vendor/autoload.php';
182+
---------
183+
184+
$db = Database::initialize('****', [user, password, database, or, other settings], **optional storage tag);
185+
186+
Is same as:
187+
188+
$setting = new Config('****', [user, password, database, or, other settings]);
189+
$db = new ez_****($settings);
165190

166191
**ezsql** functions
167192
---
@@ -192,7 +217,8 @@ To install........
192217

193218
**$db = new db** -- Initiate new db object.
194219

195-
****ezsql** variables**
220+
**ezsql** variables
221+
---
196222

197223
**$db->num-rows** – Number of rows that were returned (by the database) for the last query (if any)
198224

@@ -214,11 +240,11 @@ To install........
214240

215241
**$db->cache-timeout –** Number in hours (see mysql/disk-cache-example.php)
216242

217-
**$db = new db**
243+
____db = new db____
218244

219-
$db = new db -- Initiate new db object. Connect to a database server. Select a database.
245+
__$db = new db__ -- Initiate new db object. Connect to a database server. Select a database.
220246

221-
**Description**
247+
____Description____
222248

223249
**$db = new db**(string username, string password, string database name, string database host)
224250

@@ -230,24 +256,24 @@ Example
230256

231257
```php
232258
// Initiate new database object..
233-
$db2 = new db(”user-name”, ”user-password”, ”database-name”, “database-host”);
259+
$db2 = new db(”user-name”, ”user-password”, ”database-name”, “database-host”); // version 2 and 3
234260

235261
// Perform some kind of query..
236-
$other-db-tables = $db2->get_results(“SHOW TABLES”);
262+
$other_db_tables = $db2->get_results(“SHOW TABLES”);
237263

238264
// You can still query the database you were already connected to..
239-
$existing-connection-tables = $db->get_results(“SHOW TABLES”);
265+
$existing_connection_tables = $db->get_results(“SHOW TABLES”);
240266

241267
// Print the results from both of these queries..
242268
$db->debug();
243269
$db2->debug();
244270
```
245271

246-
**$db->select**
272+
__$db->select__ - for **mysql** only.
247273

248-
$db->select -- select a new database to work with
274+
___$db->select___ -- select a new database to work with
249275

250-
**Description**
276+
____Description____
251277

252278
bool **$db->select**(string database name)
253279

@@ -269,11 +295,11 @@ $total-hours = $db->get_var(“SELECT sum(time-logged-in) FROM user-stats WHERE
269295
$db->select(“users”);
270296
```
271297

272-
**$db->query**
298+
____$db->query____
273299

274-
$db->query -- send a query to the database (and if any results, cache them)
300+
__$db->query__ -- send a query to the database (and if any results, cache them)
275301

276-
**Description**
302+
____Description____
277303

278304
bool **$db->query**(string query)
279305

0 commit comments

Comments
 (0)