[development] Flex API, XML API modules are they needed?

David Metzler metzlerd at metzlerd.com
Wed Feb 11 03:22:26 UTC 2009


Actually not quite, in it's simplest form a key into an associative  
array and a xpath into a simpleXML object are achieving the same goal.

$xml_row->xpath('column_name')
$array_row['column_name']

All I did was make my binding layer work with either, so you could  
pass an associative array OR a parsed SimpleXML object into the  
db_query call as the parameter set.  Since I used a bracketed syntax  
rather than one like %d, I did a simple thing of saying if is_object 
($parms) then assume its xml and call an xpath method returning the  
first value to get the string replacement.

> DBTNG does not allow the reuse of placeholders within the same  
> query, because PDO doesn't either.

This was a primary concern for me.  I still haven't figured out why  
database drivers never do this....?  It seems so straightforward to  
think of parameters as key value pairs.  What I did here was to  
rewrite the parameters array into one that was numerically based  
because hey the postgres driver needed numerical bind arguments. I  
just got tired of hand rolling arrays arrays as parameters when I had  
a perfectly good $form_values array or simplexml object to use as the  
parameter source.

If DBTNG allows extra parameters to be passed that don't get used in  
the query then it's probably close enough for what most people need,  
and the XML to array conversion api would get you the rest of the way  
there anyway.

Anyway thus far what I'm hearing is the xml_to_array conversion  
utility is the most desirable.  And I haven't heard of anyone talking  
much Flex.  At one point Dries seemed pretty interested (back in  
2007) but I haven't heard much recently on this front.

Does that make things clearer?


Dave

On Feb 9, 2009, at 2:00 PM, Larry Garfield wrote:

>
> On Mon, 9 Feb 2009 12:16:12 -0500, Andrew Berry  
> <andrewberry at sentex.net> wrote:
>> On 9-Feb-09, at 12:40 AM, David Metzler wrote:
>>
>>> XML-enabled DB Binding:  Write sql binding syntax that looks like
>>> SELECT * from table where name={xpathtofield}.  The XPATH entry can
>>> also be an index to a field array.  I find this more intuitive than
>>> the %1, %2 ,etc syntax that's used in drupal, cause you can
>>> reference the same bind variable more than once in an SQL statement.
>>
>> I believe this is solved in DB:TNG, now in Drupal 7. Calls to
>> db_query() now have array keys, which can be used instead of the
>> traditional ordered placeholders.
>>
>> http://api.drupal.org/api/function/db_query/7
>>
>> --Andrew
>
> That's a different question, I think.  DBTNG uses arrays and named  
> placeholders.  It sounds like David is talking about XPath based  
> queries, which are another animal entirely and not DB portable.   
> David, can you elaborate here?
>
> DBTNG does not allow the reuse of placeholders within the same  
> query, because PDO doesn't either.
>
> --Larry Garfield
>



More information about the development mailing list