Select query
Method 1 :
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('fname', 'lname')));
$query->from($db->quoteName('#__students'));
$db->setQuery($query);
$row = $db->loadAssocList();
Method 2 :
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('fname', 'lname')));
$query->from($db->quoteName('#__students'));
$db->setQuery($query);
$row = $db->loadRowList();
return $row[0][0];
Access individual values:
Method 1
echo $row[1]['lname'];
Method 2 :
echo $row[1][1];
Method 1 :
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('fname', 'lname')));
$query->from($db->quoteName('#__students'));
$db->setQuery($query);
$row = $db->loadAssocList();
Method 2 :
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('fname', 'lname')));
$query->from($db->quoteName('#__students'));
$db->setQuery($query);
$row = $db->loadRowList();
return $row[0][0];
Access individual values:
Method 1
echo $row[1]['lname'];
Method 2 :
echo $row[1][1];
No comments:
Post a Comment