[development] programming question (drupal specific)
Tadej Baša
tadej.basa at gmail.com
Wed Sep 13 18:03:33 UTC 2006
VJ Rao pravi:
> Whats the difference between these two code snippets (1 works, 2 doesnt) :
>
> 1)
>
> $nresult = db_query('SELECT n.nid, n.body, n.type, n.title, n.promote,
> n.moderate, n.teaser, n.created, n.changed, u.name FROM {node} n ,
> {users} u, {term_node} tn, {users_roles} ur where n.uid = u.uid AND
> n.nid=tn.nid AND u.uid=ur.uid AND n.status = 1 AND n.created > %d
> ORDER BY n.created', $period);
>
> $nodes = array();
>
> while ($node = db_fetch_object($nresult)) {
> $nodes[$node->nid] = $node;
> }
>
> 2)
>
> $nresult = mysql_query('SELECT n.nid, n.body, n.type, n.title,
> n.promote, n.moderate, n.teaser, n.created, n.changed, u.name FROM
> node n , users u,term_node tn, users_roles ur where n.uid = u.uid
> AND n.nid=tn.nid AND u.uid=ur.uid AND n.status = 1 AND n.created >
> $period ORDER BY n.created');
You should use " (double quotes) if you want the *value* of $period to be inserted ...
> $nodes = array();
>
> while ($row = mysql_fetch_array($nresult, MYSQL_NUM))
> {
> $nodes[$node->nid] = $node;
>
> }
>
> Regads,
>
> V
>
More information about the development
mailing list