Home > phpMyAdmin, Summer of Code 2011 > Drizzle support for phpMyAdmin – week 10

Drizzle support for phpMyAdmin – week 10

Long story short – I decided to change my task for this week and write a database interface library working with Drizzle PHP module. After fighting with multiple segmentation faults and working around some of them I pushed working code to my repository. Longer version is below, maybe it will help someone to get started with Drizzle + PHP.

After some more thinking about my task for this week I decided to change it and implement database interface module for Drizzle, so I would have a lot of time to improve it and fix bugs while working on other features. So, I started googling for any information on Drizzle PHP extension and found out that there is currently no documentation available, but fortunately there is one old blog post on Zend Developer Zone (Getting started with Drizzle) and an example of usage provided with the extension itself (drizzle.php). Unfortunately getting the module to work on Windows would be too time consuming, so I had to compile it in my virtual machine (hint – broken build against drizzle PPA bug has information on how to quickly fix configure to work). After all the downloading, installing and compiling was done I could start working on my code.

At first I digged for more information on PHP module’s interface with the nice php --re drizzle command and some reflection code that I wrote:

<?php
function printMethod(ReflectionMethod $method) {
    if ($method->isStatic()) echo '<tt>static</tt> ';
    echo '<b>' . ($method->returnsReference() ? '&' : '') . $method->getName() . '</b>';
    echo ' ( ';
    foreach ($method->getParameters() as $par) {
        /* @var $par ReflectionParameter */
        if ($par->getPosition() > 0) echo ' , ';
        if ($par->isOptional()) echo '<u>';
        echo $par->getClass() . ' ';
        echo '<i>' . ($par->isPassedByReference() ? '&' : '') . '$' . $par->getName() . ($par->isArray() ? '[]' : '') . '</i>';
        if ($par->allowsNull()) {
            echo ' null ';
        }
        if ($par->isDefaultValueAvailable()) {
            echo ' = ';
            var_dump($par->getDefaultValue());
        }
        if ($par->isOptional()) echo '</u>';
    }
    echo ' ) ';
}

function printClass($c)
{
    $rf = new ReflectionClass($c);
?>
<h1><?=$c?></h1>
<div>
    <b>Constants</b>
    <ul>
    <?php foreach ((array)$rf->getConstants() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Default properties</b>
    <ul>
    <?php foreach ((array)$rf->getDefaultProperties() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Properties</b>
    <ul>
    <?php foreach ((array)$rf->getProperties() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Constructor</b>
    <ul><li><?php printMethod($rf->getConstructor()) ?></li></ul>
</div>
<div>
    <b>Methods</b>
    <ul>
    <?php foreach ((array)$rf->getMethods() as $v): ?>
        <li><?php printMethod($v); ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<?
}

echo '<hr />';

printClass('Drizzle');
echo '<hr />';
printClass('DrizzleCon');
echo '<hr />';
printClass('DrizzleQuery');
echo '<hr />';
printClass('DrizzleResult');
echo '<hr />';
printClass('DrizzleColumn');

After a few hours I had some code for tests, and then the real trouble began – segmentation faults, in various places and configurations. I was able to get my code to work without crashing PHP in the middle of script processing, but I decided to ignore crashes which happen at shutdown and added some code which hides this problem (flushing on shutdown). While trying to get around it I gathered some information and use cases which later went to PHP module’s bugtracker, so hopefully someday it will get fixed.

The code is in my GIT repository and mostly works, but it’s not ready for use in stable version of phpMyAdmin due to instability of PHP module. For now the code crashes PHP on most pages and has a lot of logging which gives some insight into interaction with drizzle module.

During the next week I will go on with my work on database synchronize.

Categories: phpMyAdmin, Summer of Code 2011 Tags:
  1. No comments yet.
  1. No trackbacks yet.