Hello,

Attached is a tiny patch to use db_placeholder() instead of implode() in tac_lite_node_access_records(). I'm using this patch on a development instance and it's been working fine.

Thanks for all your work on tac_lite!
-G

CommentFileSizeAuthor
tac-lite-6.x-db-placeholder.patch788 bytesgdl

Comments

Dave Cohen’s picture

Status: Active » Needs work

Nice. But shouldn't just the calls the implode() be replaced? The query string should still have the %s placeholders, right?

gdl’s picture

Nope. db_placeholders returns a string of type-appropriate placeholders, one placeholder for each element in an array. Since the elements of the arrays $vids or $all_tids are integers, it will create a string like "%d, %d, %d" for the $vids = (1,2,3). These placeholders will be filled by db_query with the appropriate values from the arrays passed as arguments to it.

I hope that's a good explanation!
-G

AlexisWilke’s picture

Dave,

db_query() knows how to handle arrays. In gdl example the (1, 2, 3) can come from $vid = { 1, 2, 3 };

Actually, many Core and 3rd party modules use array to generate an SQL statement that varies (i.e. if you add a WHERE nid = %d then you need a corresponding item in the array.)

Thank you.
Alexis

Dave Cohen’s picture

Assigned: Unassigned » Dave Cohen
Status: Needs work » Reviewed & tested by the community

Makes sense, thanks. I'll get it in there.

vladimiraus’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (outdated)

Drupal 6 is no longer supported.