To be clear, I'm looking for documentation on the Drupal 6 database API... I'm already successfully using db_query and db_fetch_object, though it was a PITA for someone used to PHP "mysql_" programming
I saw that (and did much googling) long before posting my request.
The API section shows the implementation of the various functions. That's useful to someone doing database abstraction work in the Drupal app itself, but it does little to help anybody using the db_query and db_fetch_object functions when developing modules.
Clarifying again, I'm looking for usage docs for the database access functions available in Drupal 6.
I already saw (and followed) the "Creating Modules" block tutorial, but the "Database Access" article is a lot more helpful. Who would have thought to look under "Writing Secure Code" ;-/
Given that my problem lay more with fetching, I guess my bigger problem is that I'm a procedural guy that can get a little lost in object land. "The attributes of this object are the table fields selected by the query" in the db_fetch_object API doc (or, for that matter, the name of the function itself) didn't really impress upon me that I would need object syntax to access the result (as opposed to array indexing, which was generating php errors).
I finally got the block executing properly last night after circling back to the block tutorial, and that's when I realized that I needed a firmer grounding in this.
Thanks again
One other thing - does the ':variable' replacement syntax not work in Drupal 6, or was I doing something else wrong?
Comments
looking specifically for documentation
To be clear, I'm looking for documentation on the Drupal 6 database API... I'm already successfully using db_query and db_fetch_object, though it was a PITA for someone used to PHP "mysql_" programming
http://api.drupal.org/api/gro
http://api.drupal.org/api/group/database/6 perhaps?
And http://drupal.org/node/2497?
Granted they are not as thoroughgoing.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
thanks, but no...
I saw that (and did much googling) long before posting my request.
The API section shows the implementation of the various functions. That's useful to someone doing database abstraction work in the Drupal app itself, but it does little to help anybody using the db_query and db_fetch_object functions when developing modules.
Clarifying again, I'm looking for usage docs for the database access functions available in Drupal 6.
Those, along with
Those, along with http://drupal.org/node/101496 and http://drupal.org/node/206759 (which along with some of its siblings has some examples) are the best I can come up with for now. db_fetch_object() should be straightforward - as http://api.drupal.org/api/function/db_fetch_object/6 says you get the field values by looking at the object's properties/attributes. http://api.drupal.org/api/function/db_query/6 is a bit more weird but the other links I've posted should help you work out how it works.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
ah
I already saw (and followed) the "Creating Modules" block tutorial, but the "Database Access" article is a lot more helpful. Who would have thought to look under "Writing Secure Code" ;-/
Given that my problem lay more with fetching, I guess my bigger problem is that I'm a procedural guy that can get a little lost in object land. "The attributes of this object are the table fields selected by the query" in the db_fetch_object API doc (or, for that matter, the name of the function itself) didn't really impress upon me that I would need object syntax to access the result (as opposed to array indexing, which was generating php errors).
I finally got the block executing properly last night after circling back to the block tutorial, and that's when I realized that I needed a firmer grounding in this.
Thanks again
One other thing - does the ':variable' replacement syntax not work in Drupal 6, or was I doing something else wrong?
>does the ':variable'
>does the ':variable' replacement syntax not work in Drupal 6
No it doesn't, you have to use the '%s', %d etc.
Also, if the parameters/arguments are constants you can safely put them directly in the query string.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
got it
thanks again
:)
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk