The code belows how objects can be fetched from a database with Joomla and pure php / mysql. The main differences in syntax are the database connection variable and the naming of the database table. The two examples below clearly show the differences.
$db =& JFactory::getDBO();
$query = “SELECT name from #__mytable WHERE enabled=1 “;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo “<b>”.$row->name.”</b> records which are enabled.<br/><hr>”;
}
PHP / MYSQL
$query = “SELECT name from mytable WHERE enabled=1 “;
$result = mysqli_query($db, $query);
while ($row=mysqli_fetch_object($result)) {
$myname=$row->name;
echo $myname;
}
© 2018 ALL Rights Reserved | Sitemap
Vancouver | North Vancouver | Burnaby | Richmond | Coquitlam | Port Coquitlam | Surrey | Langley | Maple Ridge | Mission | Abbotsford | Kamloops | Kelowna | Victoria | Squamish | Whistler | Pemberton