0

Job Security

See if you can spot the logic error:

<?php
    require_once "mnnl.pnnl";
 
    $tkkl = new $fkkl($_POST["wkkl"]);
 
    $tkkl->pkkl()->jkkl(14, 15, blt);
 
    foreach($tkkl->lkkl($tkkl::BkklBokkl) as &$jkkl)
    {
        jkkljokkl($jkkl);
 
        if($jkll->brkll == blt)
            hbblhobbl($jkkl);
 
        $skzzl = "SELECT fkkl, fakkl FROM frzzlz WHERE frzzlor = 'fazzor' AND fwippl IS NOT NULL";
 
        $hobbl = new hobblDobbl(hobblDobbl::$swbbl("fraaa"));
 
        $hobbl->hwaah($skzzl);
 
        $jkkl->hzrnn($hobbl->fkkl, $hobbl->fakkl);
 
        $tkkl->znnado($jkkl->twng);
    }
 
    $mbnf->swmlel($tkkl->ploo());
?>
6

PostgreSQL arrays and PHP’s str_getcsv()

Yesterday, while trying to figure out the best way to deal with PostgreSQL arrays in PHP, I came across the new str_getcsv() function in PHP as of 5.3. This function works much the same as fgetcsv to parse a CSV line, except that it works on a string instead of a file.

For quick reference, CSV looks like this:

"My Name",14,"32,000","2009-04-15"

And the return value of a PostgreSQL array looks like this:

{"My Name",14,"32,000","2009-04-15"}

Notice the similarities?

We can use PHP’s trim and str_getcsv to turn this PostgreSQL array into a PHP array:

<?php
    $data = str_getcsv(trim($record->value, "{}"));
?>

Simple as simple does. As long as your array has only a single dimension. If you’re using multidimensional arrays in PostgreSQL then you’re dead to me.

Copyright © 2010 — phup 'n stuff | Site design by Trevor Fitzgerald