Saturday, 03 August 2013 22:39

how to insert,update,delete data in joomla tables

Written by 
Rate this item
(0 votes)
how to insert data in specific joomla table? this way -

$database = JFactory::getDBO();
$database->setQuery("INSERT INTO `#__tablename` (`id`, `TicketId`,`Requested`)
values('', '".$database->getEscaped(trim($_REQUEST['tktnum']))."',
'".JFactory::getDate()->toFormat()."')");
$database->query();
if ($database->getErrorNum()) { echo "records inserting failed";}
else { echo "record inserting completed successfully"; }

here $database->getErrorNum() call is essential to determine
whether inserting was successful or a failure.

how to update data row in specific joomla table?

It's the same way as above but query will be update query like this one -
$database->setQuery("UPDATE `#__mysqltable` SET `Status`='1'
WHERE `TicketId`='1'");

how to delete data row in specific joomla table?

It's also the same way as i wrote above.An example of the query -
$database->setQuery("delete from `#__phptablename` where `id`='5'");

If you have questions about this post or any topics, post your questions in
discussions/forum in this website, you will get your answer

Read 3937 times Last modified on Monday, 19 August 2013 14:35
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.