hypercode/queryrunner

A form to create and execute querys using PHP.

1.0.0 2021-01-02 23:57 UTC

This package is auto-updated.

Last update: 2024-09-29 05:43:04 UTC


README

Using the packages Query and DatabaseConnection, use the QueryRunner. A form to create and execute querys using PHP.

First step is set a database.

ConnectionManagement::setDatabase([
'db' => [
    "driver" => "psql",
    "host" => "localhost",
    "port" => "8080",
    "dbname" => "clients_db",
    "user" => "root",
    "password" => "1234",
]
]);

Now, you can use normally QueryRunner.

QueryRunner use the same form of Query from Hyper. First, you build query

$query = new QueryRunner;
$query->select('TableName', 'name,age,created_by');

After that, you can use three methods to execute the query.

fetch

Execute query and return just the first result.

$query->select('TableName')->fetch();

fetchAll

Execute query and return all result inside of a array.

$query->select('TableName')->fetchAll();

execute

Execute query and return rows number affects.

$query->select('TableName')->execute();