Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
Project Renamed
Readme Updated
  • Loading branch information
chamamme committed Aug 18, 2018
1 parent fe15038 commit b971cef
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
9 changes: 5 additions & 4 deletions layers/Tablet.php → Builder.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
namespace Orcons\Layers;
namespace NoQuery;
/**
* User: Klaus
* Date: 9/18/2017
* Time: 1:55 PM
* @property string where
*/
class Tablet
class Builder
{

public $db;
Expand Down Expand Up @@ -123,8 +123,9 @@ public function select (array $columns=[]){
* @return $this
*/
public function where (array $conditions) {
#Ceheck if there is where already in the sql statement;
#@TODO Allow string conditions
if($conditions){
#Check if there is where already in the sql statement;
$contains_where = stripos($this->sql," WHERE ");
$conditions = implode(' AND ',$conditions);
// die($conditions);
Expand All @@ -133,7 +134,7 @@ public function where (array $conditions) {
throw new Exception("Conditions variable must be set and must be an array");
}
if($contains_where == false){
$sql =$this->sql." WHERE {$conditions}";
$sql = $this->sql." WHERE {$conditions}";
}else{
$sql =$this->sql." AND {$conditions}";
}
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@


# Orcons-db
Orcons-db is a query builder for ADODB library. It is aimed at making database interactions easier with less codes.
# NoQuery
NoQuery is a php query builder running on ADODB library. It is aimed at making database interactions easier with less codes.
NoQuery currently supports MySQL, Firebird-Interbase, PostgreSQL, SQLite3, Oracle, Microsoft SQL Server, Foxpro ODBC, Access ODBC,
Informix, DB2, Sybase, Sybase SQL Anywhere, generic ODBC and Microsoft's ADO due its leverage on ADODB.
## Installation
> composer install orcons-db
> composer install noquery

## Configuration
orcons-db requires a configuration array. A typical configuration looks like
NoQuery requires a configuration array. A typical configuration looks like

```php

$config = [
'driver' => 'mysqli',
'driver' => 'mysqli',

'server' => "localhost",

Expand All @@ -30,7 +32,7 @@ Orcons-db is a query builder for ADODB library. It is aimed at making database i
## Usage
It all starts with an instance of Tablet class which requires a configuration array variable.
```php
$db = new Orcons\Layers\Tablet( $config )
$db = new NoQuery\Builder( $config )
```
Now we are ready to interact with our database.

Expand All @@ -53,7 +55,7 @@ Now we are ready to interact with our database.
### Sample
```php

use Orcons\Layers\Tablet;
use NoQuery\Builder;

$config = [
'driver' => "mysqli",
Expand All @@ -65,18 +67,18 @@ $config = [
'debug' => true
];

$db = new Tablet( $config )
$db = new Builder( $config )

#select query
$db->table('users')
->select(['name','gender','age'])
->get()
->get();

#update statement
$db->table('users')
->update(['name'=>'Chamamme'])
->where(["id = 5","gender ='male'"])
->go()
->go();

```

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chamamme/orcons-db",
"description": "A database query builder for ADODB which is aimed at code beautification by minimizing the use of raw SQL in codes",
"name": "chamamme/noquery",
"description": "A database query builder aimed at code beautification by minimizing the use of raw SQL in codes. NoQuery currently supports MySQL, Firebird & Interbase, PostgreSQL, SQLite3, Oracle, Microsoft SQL Server, Foxpro ODBC, Access ODBC, Informix, DB2, Sybase, Sybase SQL Anywhere, generic ODBC and Microsoft's ADO due to its leverage on ADODB",
"authors": [
{
"name": "Andrew Chamamme",
Expand All @@ -9,7 +9,7 @@
}
],
"license": "MIT",
"keywords" : [ "database","adodb","orcons", "abstraction", "layer", "library", "php","query builder" ],
"keywords" : [ "noquery", "database","adodb","orcons", "abstraction", "layer", "library", "php","query builder","MySQL", "Firebird" , "Interbase", "PostgreSQL", "SQLite3", "Oracle", "Microsoft SQL Server", "Foxpro ODBC", "Access ODBC", "Informix", "DB2", "Sybase", "Sybase SQL Anywhere", "generic ODBC", "Microsoft ADO" ],
"require": {
"php": "^7.0",
"adodb/adodb-php": "5.20.9"
Expand All @@ -21,7 +21,7 @@
},
"autoload": {
"psr-4":{
"Orcons\\" : ""
"NoQuery\\" : ""
}
}
}
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'driver' => 'mysqli',
'driver' => 'mysqli', // access,ado,ibase,fbsql,db2,informix,ldap,mssqlnative,netezza,odbc,odbtp,oci8,pdo,postgres9,proxy,ads,sybase_ase,sqlite3,sybase,
'server' => "localhost",
'username' => "root",
'password' => "",
Expand Down
20 changes: 0 additions & 20 deletions index.php

This file was deleted.

20 changes: 20 additions & 0 deletions sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
require "vendor/autoload.php";

use NoQuery\Builder;

$config = require "config.php";

$db = new Builder($config);

#select query
$das = $db->table('users')
->select(['name','email'])
->get();
var_dump($das);
#update statement
$db->table('users')
->update(['name'=>'Chamamme'])
->where(["id = 5","email = '[email protected]'"])
->go();

0 comments on commit b971cef

Please sign in to comment.