Sql Class An SQL abstraction library for PHP

Getting Started

Usage

Getting Started

View the API Documentation for this class

Queries

Running a basic query and getting the results:

$result = $sql->query("SELECT stuff FROM table WHERE id = ?", [$id]);
foreach ($result as $row) {
    echo $row["stuff"] . "\n";
}

Updating records in a table:

$sql->update("table", [
    "field2"    =>  "new-value",
], [
    "field1"    =>  "today",
]);

# UPDATE `table` SET `field2` = 'new-value' WHERE `field1` = 'today'

Inserting new records into a table:

$sql->insert("table", [
    "field1"    =>  "tomorrow",
    "field2"    =>  "value",
]);

# INSERT INTO `table` (`field1`, `field2`) VALUES ('new-value', 'today')

Deleting records from a table:

$sql->delete("table", [
    "field1"    =>  "yesterday",
]);

# DELETE FROM `table` WHERE `field1` = 'yesterday'