[Solar-talk] Patch for Solar_Content_Abstract

Travis Swicegood development at domain51.com
Mon Oct 2 14:16:33 PDT 2006


Howdy all,

Paul M Jones wrote:
> Hey Travis --
>
> Sorry to top-post here, but I want to keep your patch inline *and*  
> show you this link:
>
>    <http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html>
>
> That's where the SQL commands come from; it explains the need for the  
> HAVING clause.  Read that (if you have not already) and then we can  
> continue the discussion.
>
> With respect to the COUNT(), I'm surprised that SQLite isn't carrying  
> the names forward.  Can you check if this is a known issue in your  
> version of SQLite?  If it's the expected behavior, I'll see what I  
> can do to reformat the query so that it works properly under that  
> system.
>   

The article does make sense.  The kicker, as we discussed earlier, is 
that SQLite doesn't seem to like the following SQL:

HAVING COUNT(id) = "1"

But it will accept:

HAVING COUNT(id) = 1

Seems that version SQLite 3.2.8 has issues with quotes around numeric 
values.  Anyone else hit this problem?

The solution, of course, is to not quote that value.  The having() call 
can be modified to the following:

->having('COUNT(nodes.id = ' . count(tags))

But that doesn't fix the larger issue, that all integers that are passed 
through the quoting mechanisms will (may?) not work properly.  The long 
term solution is to fix the SQL escaping to look to is_numeric() or some 
other similar function to figure out if it should be escaped.

Anyone have any comments on this?  There's a bug open at in Trac:
    http://solarphp.com/trac/ticket/10

-Travis


More information about the solar-talk mailing list