ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:proxy:proxy_index

This is an old revision of the document!


ADOdb Proxy Server

Introduction

The ADOdb Proxy server provides a simple method of extending a database connection to provide a simple REST server via http. It provides a limited number of ADOdb commands that can be executed across an http channel against any supported database.

Server Side Usage

  • The machine that acts as a database server must have a PHP configuration installed that allows it to serve PHP connections to the necessary database.
  • The http server must have a CGI configuration defined that allows it to serve PHP requests.
  • A single program is provided that acts as a server side dispatcher, server.php. Up to ADOdb version 5.21, this program cannot be moved from the /adodb directory. This program must be modified in-situ to provide the database connection necessary.

Modify the server.php as required to provide a database connection

/*
 * Define the IP address you want to accept requests from
 * as a security measure. If blank we accept anyone
 */
$ACCEPTIP = '192.168.0.65';
 
/*
 * Connection parameters
 */
$driver = 'mysqli';
$host = 'localhost';
$uid = 'proxy';
$pwd = 'proxy';
$database = 'employees';

Client Side Usage

Configuration of the client side differs only slightly from the normal ADOdb configuration.

include '../adodb-master/adodb.inc.php';
/*
* We must manually include the driver that is used on the server side. This is
* so that database specific objects can be correctly interpreted on the client
* side
*/
include '../adodb-master/drivers/adodb-mysqli.inc.php';
 
$db = ADOnewConnection('proxy');
 
/*
* Connection honors $ADODB_FETCH_MODE, but not $db->setFetchMode();
*/
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
 
/*
* define a connection directly to the server program
*/
$url = 'http://192.168.1.109/adodb-master/server.php';
 
/*
* Create a connection
*/
$db->connect($url);
 
/*
* Create an SQL command
*/
$sql = "SELECT * FROM employees";
 
/*
* Execute and treat exactly the same as a normal ADOdb result set
*/
$result = $db->selectLimit($sql,1,10);
while ($r = $result->fetchRow())
  print_r($r);

Limitations

  • Access currently limited to http protocol
  • No access to meta functions
  • No rollback or transactional control
  • No parameter binding allowed
  • server.php must be modified in-situ
v5/proxy/proxy_index.1574910338.txt.gz · Last modified: 2019/11/28 04:05 by peterdd