Thursday, September 2, 2010

PHP is so much easier to get something out than Java. Less typing, a simple example is a db access.

$dsn = 'mysql://root:workflow@localhost';
$mdb2 = & MDB2::factory($dsn);

echo ("error connecting to db\n");
echo($mdb2->getMessage().' - '.$mdb2->getUserInfo());
echo("connected !!! yay....\n");
$setDB = 'use test';
$dbSet = $mdb2->query($setDB);
echo("mysql db not set\n");
echo("db test selected\n");
$query = 'SELECT * from test';
$result = $mdb2->query($query);

echo("query results returned\n");
$array = $result->fetchRow();

The programming idioms are so easy to use and the source is available. This is so easy to figure out, less than 10 minutes after a websearch. Cut and paste the code then just add queries and use the MDB2 error handler. The code is self explanatory, no need to look at any documentation on how library functions work or where they are. A good lesson for XCode and Java libraries.

No comments:

Post a Comment