2017 © Pedro Peláez
 

library mysql

MySQL Library for plain php and other applications

image

flo5581/mysql

MySQL Library for plain php and other applications

  • Tuesday, March 21, 2017
  • by flo5581
  • Repository
  • 2 Watchers
  • 0 Stars
  • 157 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 29 Versions
  • 1 % Grown

The README.md

MySQL helper for any PHP Project

Installation

require flostone/mysql-plainphp
, (*1)

Usage

Include the class using
use FloStone\MySQL\MySQL;
Connect to the database using
$sql = MySQL::connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
Now execute queries with the query function
$results = $sql->query("SELECT * FROM projects");
The results will always be returned immediately however you can also get the results using
$results = $sql->results();, (*2)

Using Statements

If you want to make it a little easier you can also use several statements as functions.
E.g. if you wanted to make a where clause you could also write
$projects = $sql->select('*')->where('id', '=', 1)->get();
In order to use these statements you first have to specify a table:
$sql->table('projects');
The table name will stay the same for every query until you eventually change it.
You can also chain the table with several statements:
$projects = $sql->table('projects')->select('*')->where('name', 'like', '%Test%')->orWhere('title', '=', 'Testingproject')->get();
Generally it works as the Laravel Eloquent Builder, which it is based on.
, (*3)

Available Statements

public function insert(array $columns, array $values);
public function create($table, $closure)
public function update($id, array $columns, array $values);
public function drop($table);
public function table($table);
public function select($select = '*');
public function where($column, $operator, $value = NULL);
public function orWhere($column, $operator, $value = NULL);
public function whereIn($column, array $values);
public function join($table, $primary, $operator, $other = NULL);
public function leftJoin($table, $primary, $operator, $other = NULL);
public function rightJoin($table, $primary, $operator, $other = NULL);
public function outerJoin($table, $primary, $operator, $other = NULL);
public function fullOuterJoin($table, $primary, $operator, $other = NULL);
public function orderBy($column, $order = 'desc');
public function all()
public function raw($sql);
public function columnExists($column);
In some cases the operator may also be the value, in that case the operator will be set to '=' by default.
, (*4)

Create function closure

When you want to use the "create" function, you need to pass in a closure or anonymous function as second argument.
This function takes one parameter:
function($table){}
The table parameter is a "Blueprint" instance, which is used to define certain fields in you table.
A basic example of a create query could look like this:
$sql->create('projects', function(Blueprint $table){ $table->increments(); $table->string('name'); $table->timestamps(); });
, (*5)

Blueprint functions

public function increments($name = 'id');
public function string($name, $null = false, $length = 255);
public function integer($name, $null = false, $unsigned = false);
public function text($name, $null = false);
public function custom($customquery);
public function timestamps();
A custom query must be implemented as one column definition:
tinyint(1) DEFAULT 0 NOT NULL
, (*6)

The Versions

21/03 2017

dev-master

9999999-dev

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

15/01 2017

1.2.6

1.2.6.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

15/01 2017

1.2.5

1.2.5.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

09/01 2017

1.2.4

1.2.4.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

04/01 2017

1.2.3

1.2.3.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

19/12 2016

1.2.2

1.2.2.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

29/11 2016

1.2.1

1.2.1.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

21/11 2016

1.2.0

1.2.0.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

31/10 2016

1.1.5

1.1.5.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

31/10 2016

1.1.4

1.1.4.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

17/10 2016

1.1.3

1.1.3.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

17/10 2016

1.1.2

1.1.2.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

13/09 2016

1.1.1

1.1.1.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

06/09 2016

1.1.0

1.1.0.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

21/07 2016

1.0.15

1.0.15.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

18/07 2016

1.0.14

1.0.14.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

08/07 2016

1.0.13

1.0.13.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

05/07 2016

1.0.12

1.0.12.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

09/06 2016

1.0.11

1.0.11.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

08/06 2016

1.0.10

1.0.10.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

30/05 2016

1.0.9

1.0.9.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

25/05 2016

1.0.8

1.0.8.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

25/05 2016

1.0.6

1.0.6.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

25/05 2016

1.0.5

1.0.5.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

20/05 2016

1.0.4

1.0.4.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

19/05 2016

1.0.3

1.0.3.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

19/05 2016

1.0.2

1.0.2.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

18/05 2016

1.0.1

1.0.1.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone

12/05 2016

1.0

1.0.0.0

MySQL Library for plain php and other applications

  Sources   Download

by Flo Stone