Download the PHP package jv2222/ezsql without Composer
On this page you can find all versions of the php package jv2222/ezsql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ezsql
ezsql
A class to make it very easy to deal with database connections. An universal interchangeable CRUD system.
This is Version 5 which will break users of version 4.
Mainly by:
-
The use of
namespace
in theglobal
functions ezFunctions.php file. Usage of the global functions will require the user to begin a.php
file something like: - Class properties that was accessible by magic methods
get/set
, now PSR 1 camelCase. - Renamed
select
ofez_mysqli
todbSelect
. - Renamed class method and behavior of
selecting
toselect
. selecting
, and newinserting
methods, can be called without table name, only the other necessary parameters:- The table name with prefix, can be preset/stored with methods
tableSetup(name, prefix), or setTable(name), setPrefix(append)
, if called without presetting,false
is returned. - This feature will be added to all database CRUD access methods , each method name will have an
ing
ending added.
- The table name with prefix, can be preset/stored with methods
- Removed global functions where
table
name passed in, use functions using preset table names ending withing
. - renamed cleanInput to clean_string
- renamed createCertificate to create_certificate
- added global get_results to return result sets in different formats
Version 4 has many modern programming practices in which will break users of version 3.
Version 3 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.
This library has an Database
class, an combination of the Factory pattern with an Dependency Injection container hosting. This library now is following many OOP principles, one in which, the methods properties public access has been removed. This library also following PSR-2, PSR-4, PSR-11 conventions, and mostly PSR-1, that's still an work in progress.
- More Todo...
For an full overview see documentation Wiki, which is not completely finish.
Installation
composer require ezsql/ezsql
Usage
This library will assume the developer is using some sort of IDE with intellisense enabled. The comments/doc-block area will hold any missing documentations. For additional examples see phpunit tests, The tests are fully functional integration tests, meaning the are live database tests, no mocks.
The following has been added since version 2.1.7.
General Methods
to_string($arrays, $separation = ',');
clean($string);
create_cache(string $path = null);
secureSetup(string $key = 'certificate.key',
string $cert = 'certificate.crt',
string $ca = 'cacert.pem',
string $path = '.'._DS
);
secureReset();
create_certificate(string $privatekeyFile = certificate.key,
string $certificateFile = certificate.crt,
string $signingFile = certificate.csr,
string $ssl_path = null, array $details = [commonName => localhost]
);
Shortcut Table Methods
create(string $table = null, ...$schemas);// $schemas requires... column()
column(string $column = null, string $type = null, ...$args);
primary(string $primaryName, ...$primaryKeys);
index(string $indexName, ...$indexKeys);
drop(string $table);
Example
innerJoin(string $leftTable = null, string $rightTable = null,
string $leftColumn = null, string $rightColumn = null, string $tableAs = null, $condition = EQ);
leftJoin(string $leftTable = null, string $rightTable = null,
string $leftColumn = null, string $rightColumn = null, string $tableAs = null, $condition = EQ);
rightJoin(string $leftTable = null, string $rightTable = null,
string $leftColumn = null, string $rightColumn = null, string $tableAs = null, $condition = EQ);
fullJoin(string $leftTable = null, string $rightTable = null,
string $leftColumn = null, string $rightColumn = null, string $tableAs = null, $condition = EQ);
Shortcut SQL Methods
having(...$having);
groupBy($groupBy);
union(string $table = null, $columnFields = '*', ...$conditions);
unionAll(string $table = null, $columnFields = '*', ...$conditions);
orderBy($orderBy, $order);
limit($numberOf, $offset = null)
where( ...$whereConditions);
select(string $table = null, $columnFields = '*', ...$conditions);
create_select(string $newTable, $fromColumns, $oldTable = null, ...$conditions);
select_into(string $newTable, $fromColumns, $oldTable = null, ...$conditions);
update(string $table = null, $keyAndValue, ...$whereConditions);
delete(string $table = null, ...$whereConditions);
replace(string $table = null, $keyAndValue);
insert(string $table = null, $keyAndValue);
create(string $table = null, ...$schemas);
drop(string $table = null);
alter(string $table = null, ...$alteringSchema);
insert_select(string $toTable = null, $toColumns = '*', $fromTable = null, $fromColumns = '*', ...$conditions);
Example for using prepare statements indirectly, with above shortcut SQL methods
Example for using prepare statements directly, no shortcut SQL methods used
Most of shortcut methods have counter global functions available.
They can only be access by beginning your .php
file like:
For the functions usage/docs see ezFunctions.php.
For Authors and Contributors
Contributing
Contributions are encouraged and welcome; I am always happy to get feedback or pull requests on Github :) Create Github Issues for bugs and new features and comment on the ones you are interested in.
License
ezsql is open-sourced software licensed originally under (LGPL-3.0), and the addon parts under (MIT).