PHP Classes

Simple PHP PDO API: Perform common database operations using PDO

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-09-02 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 91 All time: 9,880 This week: 118Up
Version License PHP version Categories
sapi 1.0MIT/X Consortium ...8.1Tools
Description 

Author

This package can perform everyday database operations using PDO.

It provides a class that takes a PDO database object to perform several database queries.

Currently, it can:

- Set the SQL of the query that it will execute

- Execute the SQL query to create, read or delete database table records using given parameters as arrays

- Execute the SQL query with a given parameters array and retrieve the results into an array or just a single result row

Picture of Eric AGNEL
  Performance   Level  
Name: Eric AGNEL <contact>
Classes: 2 packages by
Country: Taiwan Taiwan

Documentation

SApi

Simple CRUD api system.

About

This is a simple API class meant to be easy to use without to much configuration.

Basic Usage

The minimum setup needed to use the Logger class.

_SQL request without parameters_


<?php
require_once("vendor/autoload.php");

use Kuran\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);


_SQL request with named parameters_


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

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

_SQL request with dynamic parameters_


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

$queryParams = [2, "username"];

Class methods


// 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());


  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  src  
File Role Description
Files folder imageKuran (1 directory)

  Files folder image Files  /  src  /  Kuran  
File Role Description
Files folder imageSApi (1 file)

  Files folder image Files  /  src  /  Kuran  /  SApi  
File Role Description
  Plain text file Api.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:91
This week:0
All time:9,880
This week:118Up