To clear the previous values from the query var.
/* This needs to be added while using nesting loop to clear the previous query in Joomla Component Writing. */ $query = $db->getQuery(true);This is to print the built query or dump query.
/* This is to print the built query or dump query. */ echo $query->dump();Find the sample query as below;
$data = array(); $query->select('c.id, c.alias, c.title'); $query->from('#__categories c'); $query->where('c.alias not in ("admin") and c.extension="com_bmember" and published="1"'); $query->order('c.title asc'); $db->setQuery((string)$query); $categories = $db->loadObjectList(); if (is_array($categories) && ($categories)>0) { $i=0; foreach ($categories as $category) { $data[$i]['catid'] = $category->id; $data[$i]['category'] = $category->title; $data[$i]['attributes'] = array(); $query = $db->getQuery(true); // This needs to be added while using nesting loop to clear the previous query. $query->select('af.id, af.attribute, af.alias'); $query->from('#__bmember_attribute_fields af'); $query->where('af.catid="'.$category->id.'" and af.state="1"'); $db->setQuery((string)$query); $rows = $db->loadObjectList(); $query->order('af.attributes asc'); $i++; } }
No comments:
Post a Comment
Please post any queries and comments here.