Merge branch 'develop'

This commit is contained in:
Timothy Warren 2016-07-26 13:10:03 -04:00
commit a6131924f7
5 changed files with 54 additions and 22 deletions

View File

@ -7,6 +7,7 @@ php:
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7
- hhvm - hhvm
- nightly - nightly
@ -28,4 +29,6 @@ after_script:
matrix: matrix:
allow_failures: allow_failures:
- php: 5.3 - php: 5.3
- php: hhvm - php: 5.4
- php: 5.5
- php: nightly

View File

@ -1,10 +1,10 @@
#Contributing # Contributing
Please submit pull requests to [timw4mail/Query](https://github.com/timw4mail/Query), but other issues to [aviat4ion/Query](https://github.com/aviat4ion/Query) Please submit pull requests and issues to [aviat4ion/Query](https://git.timshomepage.net/aviat4ion/Query)
###Pull Requests ### Pull Requests
* All pull requests should have accompanying tests following the structure / makeup of the `/tests` folder * All pull requests should have accompanying tests following the structure / makeup of the `/tests` folder
* Pull requests should reference the issue number on [aviat4ion/Query](https://github.com/aviat4ion/Query), if applicable. * Pull requests should reference the issue number on [aviat4ion/Query](https://git.timshomepage.net/aviat4ion/Query), if applicable.
* Pull requests must follow project style: * Pull requests must follow project style:
1. Follow [CodeIgniter Style](http://codeigniter.com/user_guide/general/styleguide.html) 1. Follow [CodeIgniter Style](http://codeigniter.com/user_guide/general/styleguide.html)
2. Use tabs for indentation, and do not align arrays or other multiple line statements. 2. Use tabs for indentation, and do not align arrays or other multiple line statements.

27
LICENSE.md Normal file
View File

@ -0,0 +1,27 @@
# DON'T BE A DICK PUBLIC LICENSE
> Version 1, December 2009
> Copyright (C) 2012 Timothy J. Warren <tim@timshomepage.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
> DON'T BE A DICK PUBLIC LICENSE
> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. Do whatever you like with the original work, just don't be a dick.
Being a dick includes - but is not limited to - the following instances:
1a. Outright copyright infringement - Don't just copy this and change the name.
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
2. If you become rich through modifications, related works/services, or supporting the original work,
share the love. Only a dick would make loads off this work and not buy the original work's
creator(s) a pint.
3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.

View File

@ -1,30 +1,31 @@
# Query # Query
A query builder/database abstraction layer, using prepared queries for security. A query builder/database abstraction layer, using prepared statements for security.
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=query)](https://jenkins.timshomepage.net/job/query/) [![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=query)](https://jenkins.timshomepage.net/job/query/)
[![Code Coverage](https://scrutinizer-ci.com/g/timw4mail/Query/badges/coverage.png?s=a96df5417089f90250aeb59013a3964b1ff9b588)](https://scrutinizer-ci.com/g/timw4mail/Query/) [![Code Coverage](https://scrutinizer-ci.com/g/aviat4ion/Query/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/aviat4ion/Query/?branch=develop)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/timw4mail/Query/badges/quality-score.png?s=ce0f185067d7049cfe3f0aba2ca30ed56fb97b20)](https://scrutinizer-ci.com/g/timw4mail/Query/) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/aviat4ion/Query/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/aviat4ion/Query/?branch=develop)
[![Latest Stable Version](https://poser.pugx.org/aviat4ion/query/v/stable.png)](https://packagist.org/packages/aviat4ion/query) [![Latest Stable Version](https://poser.pugx.org/aviat4ion/query/v/stable.png)](https://packagist.org/packages/aviat4ion/query)
[![Total Downloads](https://poser.pugx.org/aviat4ion/query/downloads.png)](https://packagist.org/packages/aviat4ion/query) [![Total Downloads](https://poser.pugx.org/aviat4ion/query/downloads.png)](https://packagist.org/packages/aviat4ion/query)
[![Latest Unstable Version](https://poser.pugx.org/aviat4ion/query/v/unstable.png)](https://packagist.org/packages/aviat4ion/query) [![Latest Unstable Version](https://poser.pugx.org/aviat4ion/query/v/unstable.png)](https://packagist.org/packages/aviat4ion/query)
[![License](https://poser.pugx.org/aviat4ion/query/license.png)](http://www.dbad-license.org/) [![License](https://poser.pugx.org/aviat4ion/query/license.png)](http://www.dbad-license.org/)
## Requirements ## Requirements
* Pdo extensions for the databases you wish to use (unless it's Firebird, in which case, the interbase extension is required) * PDO extensions for the databases you wish to use (unless it's Firebird, in which case, the interbase extension is required)
* PHP 5.3+ * Supported version of PHP (Older versions may work, but are not supported)
## Databases Supported ## Databases Supported
* Firebird (via interbase extension) * Firebird (via interbase extension)
* Firebird (via PDO) -- experimental
* MySQL * MySQL
* PostgreSQL * PostgreSQL
* SQLite * SQLite
## Including Query in your application ## Including Query in your application
To include Query in your PHP project, just include the `autoload.php` file. This will automatically load the classes that are supported by the current PHP installation. * Install via composer and include `vendor/autoload.php`
or
* Just include the `autoload.php` file. This will automatically load the classes that are supported by the current PHP installation.
## Connecting ## Connecting
@ -35,14 +36,14 @@ Create a connection array or object similar to this:
<?php <?php
$params = array( $params = array(
'type' => 'mysql', 'type' => 'mysql', // mysql, pgsql, firebird, sqlite
'host' => 'localhost', 'host' => 'localhost', // address or socket
'user' => 'root', 'user' => 'root',
'pass' => '', 'pass' => '',
'port' => '3306', 'port' => '3306',
'database' => 'test_db', 'database' => 'test_db',
// Only required // Only required for
// SQLite or Firebird // SQLite or Firebird
'file' => '/path/to/db/file', 'file' => '/path/to/db/file',
@ -81,9 +82,9 @@ Query('old')->query($sql);
``` ```
### Running Queries ### Running Queries
Query uses the same interface as CodeIgniter's [Active Record class](http://ellislab.com/codeigniter/user-guide/database/active_record.html). However, it does not implement the `update_batch` or caching methods. Query uses the same interface as CodeIgniter's [Query Builder](http://www.codeigniter.com/user_guide/database/query_builder.html) class. However, it does not implement the `update_batch` or caching methods. For specific query builder methods, see the [class documentation](https://gitdev.timshomepage.net/Query/docs/classes/Query_QueryBuilder.html#methods).
####You can also run queries manually. #### You can also run queries manually.
To run a prepared statement, call To run a prepared statement, call
`$db->prepare_execute($sql, $params)`. `$db->prepare_execute($sql, $params)`.
@ -105,7 +106,7 @@ $query = $db->select('id, key as k, val')
->get(); ->get();
``` ```
This will generate a query similar to (with this being the output for a Postgres database): This will generate a query similar to (with this being the output for a PostgreSQL database):
```sql ```sql
SELECT "id", "key" AS "k", "val" SELECT "id", "key" AS "k", "val"
@ -117,7 +118,7 @@ LIMIT 3 OFFSET 1
``` ```
To retreive the results of a query, use the PDO method [fetch](http://php.net/manual/en/pdostatement.fetch.php) and/or [fetchAll](http://php.net/manual/en/pdostatement.fetchall.php). To retrieve the results of a query, use the PDO method [fetch](http://php.net/manual/en/pdostatement.fetch.php) and/or [fetchAll](http://php.net/manual/en/pdostatement.fetchall.php).
```php ```php
<?php <?php
@ -148,5 +149,5 @@ $query = $db->set('foo', 'bar')
->update('table'); ->update('table');
``` ```
The `set` method can also take an array as a paramater, instead of setting individual values. The `set` method can also take an array as a parameter, instead of setting individual values.

View File

@ -1,6 +1,7 @@
sonar.projectKey=query sonar.projectKey=query
sonar.projectName=Query Builder sonar.projectName=Query Builder
sonar.projectVersion=1.0 sonar.projectVersion=2.5.1
sonar.sources=src sonar.sources=src
sonar.language=php
sonar.php.coverage.reportPath=build/logs/clover.xml sonar.php.coverage.reportPath=build/logs/clover.xml
#sonar.php.tests.reportPath=build/logs/junit.xml sonar.php.tests.reportPath=build/logs/junit.xml