PHP Classes

Simple PHP PDO API: Perform common database operations using PDO

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 97 All time: 9,848 This week: 101Up
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
Age: ???
All time rank: 435210 in Taiwan Taiwan
Week rank: 180 Up2 in Taiwan Taiwan Up

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 (4)  
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 (4)  /  src  
File Role Description
Files folder imageKuran (1 directory)

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

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:97
This week:0
All time:9,848
This week:101Up