It doesent matter, which version, you are using, the following code will work. The code snippets given below canbe used freely in any place, like a model, view or a controller in joomla web programming.
$query = "INSERT INTO #__users (name, username, email, password, gid) VALUES ('$name', '$username', '$email', '$password', '$gid')";
$db->setQuery($query);
$db->query();
$query = "DELETE FROM #__users WHERE id = '$id'";
$db->setQuery($query);
$db->query();
$db = & JFactory::getDBO();
$query = "UPDATE #__users SET name='$name' WHERE id='$uid'";
$db->setQuery( $query );
$db->query();
$db = &JFactory::getDBO();
$db->setQuery($query);
$rowsc = $db->loadObjectList();
foreach($rowsc as $rowc)
{
$name=$rowc->name;
}
Inserting Data:
$db =& JFactory::getDBO();$query = "INSERT INTO #__users (name, username, email, password, gid) VALUES ('$name', '$username', '$email', '$password', '$gid')";
$db->setQuery($query);
$db->query();
Delete Data:
$db =& JFactory::getDBO();$query = "DELETE FROM #__users WHERE id = '$id'";
$db->setQuery($query);
$db->query();
Update Data:
global $mainframe;$db = & JFactory::getDBO();
$query = "UPDATE #__users SET name='$name' WHERE id='$uid'";
$db->setQuery( $query );
$db->query();
Select Data:
$query = "SELECT * FROM #__users where id='$uid' ORDER BY id desc ";$db = &JFactory::getDBO();
$db->setQuery($query);
$rowsc = $db->loadObjectList();
foreach($rowsc as $rowc)
{
$name=$rowc->name;
}
No comments:
Post a Comment