In the Drupal API 'Database abstraction layer' documentation it states that:

<?php

$result = db_query_range('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = %d', $uid, 0, 10);
while ($node = db_fetch_object($result)) {
// Perform operations on $node->body, etc. here.
  }

?>

"Curly braces are used around "node" to provide table prefixing via db_prefix_tables(). The explicit use of a user ID is pulled out into an argument passed to db_query() so that SQL injection attacks from user input can be caught and nullified. "

But do I always have to use the '$uid' for every type of query I build?

Thank you in advance for any answers. :-)

Comments

matt_harrold’s picture

No . .. not at all .... this sample code simply retrieves all nodes associated with a particular user ... you may want a totally different set of results. Carry on Dolphin Boy.