[development] programming question (drupal specific)

Maciek Perlinski maciej.perlinski at meant4.com
Wed Sep 13 18:06:56 UTC 2006


Is that the complete snippet?

//--------------------------------------------------------------------------
--

$nresult = mysql_query('SELECT n.nid, n.body, n.type, n.title,
n.promote, n.moderate, n.teaser, n.created , n.changed,  <http://u.name/>
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');

$nodes = array();

while ($row = mysql_fetch_array($nresult, MYSQL_NUM))
{
 $nodes[$node->nid] = $node;

}

//--------------------------------------------------------------------------
------------------------------------------

If so in the while statement :  $nodes[$node->nid] = $node; has no sense
because you are receiving an assoc array and keep it in $row array which has
no connection to $nodes[$node->nid]=$node;

What is $node??? What is $node->nid the only thing which contains any data
is $nresult and $row so check what your variables contain.

 

Mac

maciej.perlinski at meant4.com

 

  _____  

From: VJ Rao [mailto:cmsconsultant at gmail.com] 
Sent: Wednesday, September 13, 2006 7:33 PM
To: development at drupal.org; support at drupal.org
Subject: [development] programming question (drupal specific)

 

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 <http://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
<http://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');

$nodes = array();

while ($row = mysql_fetch_array($nresult, MYSQL_NUM))
{
 $nodes[$node->nid] = $node;

}

 

Regads,

 

V

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20060913/10b1f6dc/attachment-0001.htm


More information about the development mailing list