MySQL Storage engine using embedded PHP

Registered 2008-12-30 by Johannes Schlüter

This is an implementation of a storage engine plugin for the MySQL Server 5.1 which can be controlled using PHP

Extremely experimental storage engine for the MySQL Database Server 5.1

THIS PLUGIN IS NOT THREAD SAFE - PARALLEL REQUEST WILL SEGFAULT!
(I guess I'll have to add some mutexes when calling into PHP)

This code comes directly from the RawIdea area of my brain to code. It's my
first storage engine so some things might be weird :-)

Show case:

<?php
class Test extends ArrayIterator implements MySQLStorage_Writable, MySQLStorage_Updatable, MySQLStorage_Deletable {
    public function write($data) {
        $this[] = $data;
    }

    public function update($data) {
        $this[$this->key()] = $data;
    }

    public function delete() {
        unset($this[$this->key()]);
    }
}

function create_table($table, $data) {
    return true;
}

function open_table($table) {
    return new Test(array(
        array('id' => 1, 'a' => 'foo'),
        array('id' => 2, 'a' => 'bar')));
    }
}
?>

mysql> SELECT * FROM php_write;
+------+------+
| id | val |
+------+------+
| 1 | foo |
| 2 | bar |
+------+------+
2 rows in set (0.00 sec)

mysql> CREATE TABLE php_write (id int, val CHAR(3)) ENGINE=PHP;
Query OK, 0 rows affected (0.00 sec)
mysql> UPDATE php_write SET val = 'baz' WHERE id = 1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> DELETE FROM php_write WHERE id = 2;
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO php_write VALUES(3, 'bar');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM php_write;
+------+------+
| id | val |
+------+------+
| 1 | baz |
| 3 | bar |
+------+------+
2 rows in set (0.01 sec)

For more see the README in my branch: http://bazaar.launchpad.net/~johannes-s/mysql-php-storage/trunk/files

This product includes PHP software, freely available from <http://www.php.net/software/>
PHP includes the Zend Engine, freely available at <http://www.zend.com>.

Project information

Maintainer:
Johannes Schlüter
Driver:
Not yet selected
Development focus:

trunk series 

lp:mysql-php-storage 
Browse the code

Licences:
Simplified BSD Licence
()

RDF metadata

View full history Series and milestones

MySQL PHP Storage Engine trunk series is the current focus of development

Get Involved

  • warning
    Report a bug
  • warning
    Ask a question
  • warning
    Help translate

Downloads

MySQL PHP Storage Engine does not have any download files registered with Launchpad.