Table of Contents
ADOdb Proxy Server
This functionality is deprecated as of ADOdb 5.21.0 and will be removed in 5.22.0. It could be reinstated, if the community contributes with necessary security enhancements, as discussed on Github.
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.
Security warning - use with extreme caution ! Depending on how it is setup, this feature can potentially expose the database to attacks, particularly if used with a privileged user account.
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. For information about the client side driver, see Proxy Client
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