$sql
$sql : string
This utility is useful to create sql queries for various RDBMS.
An example of usage can be:
$passwordHasher = new Hashing\Hasher(Hashing\Algorithm::BCRYPT);
$queryBuilder = new SQLQueryBuilder(); $queryBuilder->insertInto("users")->values([ "name" => "Mario", "surname" => "Rossi", "password" => $passwordHasher->hash("Mario's password"); // good bye rainbow tables! "sex" => 0, "height" => 1.70 ]);
//INSERT INTO "users" (name, surname, password, sex, height) VALUES (?, ?, ?, ?, ?) $sql = $queryBuilder->exportQuery();
// array( "Mario", "Rossi", ".....", 0, 1.70 ) $params = $queryBuilder->exportParams();
update(string $table) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add UPDATE %tablename% to the SQL query.
string | $table | the name of the table to be updated |
the updated sql builder
set(array $values) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add SET col1 = ?, col2 = ?, col3 = ? to the SQL query.
array | $values | an associative array of columns => value to be changed |
the updated sql builder
createTable(string $tableName) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add CREATE TABLE IF NOT EXISTS %tablename% to the SQL query.
string | $tableName | the name of the table |
the updated sql builder
dropTable(string $tableName) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add DROP TABLE IF EXISTS %tablename% to the SQL query.
string | $tableName | the name of the table |
the updated sql builder
where(\Gishiki\Database\Runtime\SelectionCriteria $where) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add WHERE col1 = ? OR col2 <= ? .
...... to the SQL query.
\Gishiki\Database\Runtime\SelectionCriteria | $where | the selection criteria |
the updated sql builder
insertInto(string $table) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add INSERT INTO %tablename% to the SQL query.
string | $table | the name of the table to be affected |
the updated sql builder
values(array $values) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add (col1, col2, col3) VALUES (?, ?, ?, ?) to the SQL query.
array | $values | an associative array of columnName => rowValue |
the updated sql builder
limitOffsetOrderBy(\Gishiki\Database\Runtime\ResultModifier $mod) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add LIMIT ? OFFSET ? ORDER BY .
.... to the SQL query whether they are needed.
\Gishiki\Database\Runtime\ResultModifier | $mod | the result modifier |
the updated sql builder
selectAllFrom(string $table) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add SELECT * FROM %tablename% to the SQL query.
string | $table | the name of the table to be affected |
the updated sql builder
selectFrom(string $table, array $fields) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add SELECT col1, col2, col3 FROM %tablename% to the SQL query.
string | $table | the name of the table to be affected |
array | $fields | the list containing names of columns to be selected |
the updated sql builder
deleteFrom(string $table) : \Gishiki\Database\Adapters\Utils\SQLGenerator\SQLWrapperInterface
Add DELETE FROM %tablename% to the SQL query.
string | $table | the name of the table to be affected |
the updated sql builder