Skip to content

Commit

Permalink
v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kristuff authored Apr 23, 2020
2 parents ae2c6b8 + e1559b0 commit b239c1d
Show file tree
Hide file tree
Showing 35 changed files with 144 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ vendor/ export-ignore
.travis.yml export-ignore
composer.* export-ignore
phpunit.xml export-ignore
README.* export-ignore
README.* export-ignore
CHANGELOG.* export-ignore
1 change: 1 addition & 0 deletions .gitignore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
All notable changes to this project will be documented in this file.


## [v0.3] - 2020-04-23

### Changed
- **Possible break change** Improve output formats definition. Using abstract class Output and its constants. 'ASSO' change to 'ASSOC' for associative arrays. 'COLS' change to 'COLUMN'

## [v0.2] - 2020-04-15

### Added
- Best support for sub queries filters : when using the WHERE or HAVING clause, the prefix _PATABASE_COLUMN_LITERALL_ in the filter value allows to match with the result of the main query (insead of a non dynamic value).
- Best support for sub queries filters : when using the WHERE or HAVING clause, the prefix _PATABASE_COLUMN_LITERALL_ in the filter value allows to match with the result of the main query (instead of a non dynamic value).

### Changed
- **Possible break change** Drop support for php < 7.1
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ A database/server SQL query builder for PHP.

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/398308d1225049f58ae583065608c460)](https://www.codacy.com/app/kristuff_/patabase?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=kristuff/patabase&amp;utm_campaign=Badge_Grade)
[![Code Climate](https://codeclimate.com/github/kristuff/patabase/badges/gpa.svg)](https://codeclimate.com/github/kristuff/patabase)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kristuff/patabase/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kristuff/patabase/?branch=master)
[![Build Status](https://travis-ci.org/kristuff/patabase.svg?branch=master)](https://travis-ci.org/kristuff/patabase)
[![codecov](https://codecov.io/gh/kristuff/patabase/branch/master/graph/badge.svg)](https://codecov.io/gh/kristuff/patabase)

[![Latest Stable Version](https://poser.pugx.org/kristuff/patabase/v/stable)](https://packagist.org/packages/kristuff/patabase)
[![License](https://poser.pugx.org/kristuff/patabase/license)](https://packagist.org/packages/kristuff/patabase)

Website
-------
Expand Down Expand Up @@ -73,6 +75,19 @@ Requirements
- PHP >= 7.1
- PDO extension: Sqlite, Mysql or Postgresql

Sample of code
--------------
```php
$database = new \Kristuff\Patabase\Database(['driver' => 'sqlite', 'database' => '/somewhere/database.db']);
$database->select()
->column('customer.customerName')
->column('order.orderId')
->from('customer')
->innerJoin('order', 'customerId', 'customer', 'customerId')
->orderAsc('order.orderId')
->whereEqual('order.customerId', 222)
->getAll('json');
```

License
-------
Expand Down
2 changes: 1 addition & 1 deletion lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Datasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
*
* @copyright 2017-2020 Kristuff
*/
Expand Down
12 changes: 7 additions & 5 deletions lib/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
*
* @copyright 2017-2020 Kristuff
*/
Expand All @@ -24,6 +24,7 @@
use Kristuff\Patabase;
use Kristuff\Patabase\Driver;
use Kristuff\Patabase\Exception;
use Kristuff\Patabase\Outpout;

/**
* Class DatabaseDriver
Expand Down Expand Up @@ -59,12 +60,12 @@ abstract class DatabaseDriver
protected $error = array();

/**
* The default ouput format
* The default output format
*
* @access private
* @var string
*/
private $defaultOutputFormat = 'asso';
private $defaultOutputFormat = Outpout::ASSOC;

/**
* Options for CREATE TABLE
Expand All @@ -78,7 +79,7 @@ public function sqlCreateTableOptions()
}

/**
* Gets/returns the default ouput format
* Gets/returns the default output format
*
* @access public
* @return string
Expand Down Expand Up @@ -126,6 +127,7 @@ public function getDriverName()

/**
* Escape a given string with driver escape chars
*
* @access public
* @param string $str The value to escape
*
Expand All @@ -143,7 +145,7 @@ public function escape($str)
* @access public
* @param array $values The array of values
*
* @return string
* @return array
*/
public function escapeList(array $values)
{
Expand Down
8 changes: 6 additions & 2 deletions lib/Driver/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand All @@ -34,7 +34,7 @@ class DriverFactory
*
* @access public
* @param array $settings The connection settings
* @param bool $isServerConnection True for Server connection, default is false
* @param bool [$isServerConnection] True for Server connection, default is false
*
* @return MysqlDriver|PostgresDriver|SqliteDriver
* @throw Exception\InvalidArgException
Expand All @@ -47,12 +47,16 @@ public static function getInstance(array $settings, $isServerConnection = false)

// get driver
switch ($settings['driver']) {

case 'sqlite':
return new Driver\Sqlite\SqliteDriver($settings);

case 'mysql':
return new Driver\Mysql\MysqlDriver($settings, $isServerConnection);

case 'pgsql':
return new Driver\Postgres\PostgresDriver($settings, $isServerConnection);

default:
throw new Exception\InvalidArgException('The specified driver is not supported');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Mysql/MysqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
*
* @copyright 2017-2020 Kristuff
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Postgres/PostgresDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/ServerDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Sqlite/SqliteDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Sqlite/SqliteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/InvalidArgException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/MissingArgException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/PatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
*
* @copyright 2017-2020 Kristuff
*/
Expand Down
54 changes: 54 additions & 0 deletions lib/Outpout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* ____ _ _
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___|
*
* This file is part of Kristuff\Patabase.
*
* (c) Kristuff <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

namespace Kristuff\Patabase;

/**
* Class Constants
*
* Define api output constant constants
*/
abstract class Outpout
{
/**
* Define the constant JSON for json outpout
*/
const JSON = 'JSON';

/**
* Define the constant JSON_PRETTY_PRINT for json pretty print outpout
*/
const JSON_PRETTY_PRINT = 'JSONPP';

/**
* Define the constant OBJ for objects outpout
*/
const OBJ = 'OBJ';

/**
* Define the constant COLUMN for column outpout
*/
const COLUMN = 'COLUMN';

/**
* Define the constant ASSOC for associative array outpout
*/
const ASSOC = 'ASSOC';
}
2 changes: 1 addition & 1 deletion lib/Query/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
*
* @copyright 2017-2020 Kristuff
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Query/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Query/Having.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
8 changes: 3 additions & 5 deletions lib/Query/Insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down Expand Up @@ -72,16 +72,14 @@ public function bindValues()
}

/**
* Returns the number of rows affected by the last SQL statement
*
* Returns the ID of the last inserted row or sequence value
* This function returns false if there is no executed query.
*
* @access public
* @return int|false The number of affected rows if any, otherwise false.
* @return int|false The last inserted id if found, otherwise false.
*/
public function lastId()
{
return (empty(!$this->pdoStatement)) ? $this->driver->lastInsertedId() : false;
}

}
2 changes: 1 addition & 1 deletion lib/Query/InsertBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/Query/QueryBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.2.0
* @version 0.3.0
* @copyright 2017-2020 Kristuff
*/

Expand Down
Loading

0 comments on commit b239c1d

Please sign in to comment.