PHP code example of kuran / sapi

1. Go to this page and download the library: Download kuran/sapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kuran / sapi example snippets




uran\SApi\Api;

$db = new PDO();

$sqlQuery = "SELECT
                    users.name,
                    users.email,
                    users.address
                FROM users";

$queryParams = [];

$api = new Api($db);

$api->setQueryString($sqlQuery);

echo $api->readAll($queryParams);




$sqlQuery = "SELECT
                    users.name,
                    users.email,
                    users.address
                FROM users
                WHERE users.id = :id
                AND users.name = :name";

$queryParams = ["id" => 2, "name" => "username"];



$sqlQuery = "SELECT
                    users.name,
                    users.email,
                    users.address
                FROM users
                WHERE users.id = ?
                AND users.name = ?";

$queryParams = [2, "username"];



// readAll().
// Will fetch all matching rows from the database.
$api->readAll(array());

//readOne().
// Will fetch one matching row from the database.
$api->readOne(array());

//create().
// Insert data to the database
$api->create(array());

//update()
// Will update a row from the database.
$api->update(array());

//delete()
// Will delete an entry from the database
$api->delete(array());