lukafurlan / php-query-builder
Fast PHP query builder
1.0.0
2018-10-21 20:47 UTC
Requires
- ext-pdo: *
This package is auto-updated.
Last update: 2024-09-22 09:49:04 UTC
README
Fast PHP query builder created using PHP.
Instalation
Because of PSR-4
autoloading, this package can be installed with composer.
$ composer require 'lukafurlan/php-query-builder'
To make this package work and connect to the database you have to define these constants.
define('MYSQL_HOST', 'localhost'); define('MYSQL_DATABASE', 'database'); define('MYSQL_USERNAME', 'root'); define('MYSQL_PASSWORD', 'password');
Usage examples
Select
$queryManager = new DMLQueryManager();
$queryManager->select() ->columns(["id"]) ->from("users") ->where(["country = :country"]) ->bind([":country" => "Slovenia"]) ->execute();
Insert
$queryManager->insert() ->into("users") ->columns(["name", "country"]) ->values([ ["Luka", "Slovenia"], ["John", "England"] ]) ->execute();
Update
$queryManager->update() ->table("users") ->columns([ "country" => "Germany" ]) ->where(["country = :country"]) ->bind([":country" => "England"]) ->execute();
Delete
$queryManager->delete() ->from("users") ->where(["country = :country"]) ->bind([":country" => "England"]) ->execute();