Posted By

anagaiyahoocom on 03/09/11


Tagged

joomla


Versions (?)

Inserting a Record in Joomla Using JDatabase::insertObject()


 / Published in: PHP
 

  1. //Create row object
  2. $db = JFactory::getDBO();
  3. $row = new JObject();
  4. $row->created_by = (int)$user->id;
  5. $row->title = 'My Favorites';
  6. $row->alias = JFilterOutput::stringUrlSafe($row->title); //format in slashed alias format
  7. $row->default = 1;
  8.  
  9. //third parameter is key field
  10. $ret = $db->insertObject('#__jxgallery_lightboxes', $row, 'lightbox_id');
  11.  
  12. if (!$ret) {
  13. $this->setError($db->getErrorMsg());
  14. return false;
  15. }
  16.  
  17. //Get the new record id
  18. $lightbox = (int)$db->insertid();

Report this snippet  

You need to login to post a comment.