Eric Day

Thoughts, code, and other oddments.
Dark | Light

< || >

Drizzle PHP Extension 0.1 Released!

February 10th, 2009

Building on top of my last post, the PHP extension for the new client and protocol library is ready as well! You can download the tarball on the Launchpad download page. The PHP extension exposes the same set of client functions that the C library provides currently, and is mostly just a wrapper to provide the PHP specific handling. To install, you’ll need the PHP development packages installed (if you have ‘phpize’ command you’re all set). After extracting the tarball, just run:

phpize
./configure
make
make install

And then add the following line to your php.ini:

extension=”drizzle.so”

I realize there is no documentation at this point, we’re working on that (please get in touch if you want to get involved in any way). The provided ‘drizzle.php’ file has examples in many of the ways you can access the database, but here are a couple examples to get you started (error checking omitted for brevity):

# Simple query to a Drizzle server
$drizzle= drizzle_create();
$con= drizzle_con_add_tcp($drizzle, "127.0.0.1", 0, "root", NULL, "sakila", 0);
$result= drizzle_query($con, "SELECT * FROM film LIMIT 3");
drizzle_result_buffer($result);
while (($row= drizzle_row_next($result)) != NULL)
  print implode(':', $row) . "\n";

# Simple query to a MySQL server using the OO interface
$drizzle= new drizzle();
$con= $drizzle->add_tcp("127.0.0.1", 0, "root", NULL, "sakila", DRIZZLE_CON_MYSQL);
$result= $con->query("SELECT * FROM film LIMIT 3");
$result->buffer();
while (($row= $result->row_next()) != NULL)
  print implode(':', $row) . "\n";

# Three concurrent queries to a MySQL server using Unix Domain Sockets
$drizzle= new drizzle();
for ($x= 0; $x < 3; $x++) {
  $con= $drizzle->add_uds("/tmp/mysql.sock", "root", NULL, "sakila", DRIZZLE_CON_MYSQL);
  $drizzle->query_add($con, "SELECT * FROM film LIMIT 3", 0, $x);
}

while (1) {
  list($ret, $q)= $drizzle->run();
  if (!$q)
    break;

  $data= $q->data();
  $result= $q->result();
  while (($row= $result->row_next()) != NULL)
    print "$data " . implode(':', $row) . "\n";
}
Posted in Drizzle, Main, MySQL

One Response to "Drizzle PHP Extension 0.1 Released!"

  1. [...] Drizzle PHP Extension 0.1 Released! – De MySQL Fork Drizzle heeft natuurlijk wel de steun van de verschillende programmeer talen nodig. Inmiddels is de eerste test versie van een PHP extensie beschikbaar. [...]

Leave a Reply


< || >
Blog
Wiki
About
Resume
RSS
Comments

E-Mail
Launchpad
LinkedIn
Twitter
identi.ca
Facebook

OpenStack
Scale Stack
Gearman
NW Veg
Veg Food & Fit

Linux On Laptops