Return to Snippet

Revision: 42710
at May 14, 2011 02:46 by anagaiyahoocom


Updated Code
//Create row object
$db = JFactory::getDBO();
$row = new JObject();
$row->created_by	 = (int)$user->id;
$row->title = 'My Favorites';
$row->alias = JFilterOutput::stringUrlSafe($row->title); //format in slashed alias format
$row->default = 1;

//third parameter is key field
$ret = $db->insertObject('#__jxgallery_lightboxes', $row, 'lightbox_id');

if (!$ret) {
	$this->setError($db->getErrorMsg());
	return false;
}

//Get the new record id
$lightbox = (int)$db->insertid();

Revision: 42709
at March 9, 2011 10:06 by anagaiyahoocom


Initial Code
//Create row object
$row = new JObject();
$row->created_by	= (int)$user->id;
$row->title = 'My Favorites';
$row->alias = JFilterOutput::stringUrlSafe($row->title); //format in slashed alias format
$row->default = 1;

//third parameter is key field
$ret = $db->insertObject('#__jxgallery_lightboxes', $row, 'lightbox_id');

if (!$ret) {
	$this->setError($db->getErrorMsg());
	return false;
}

//Get the new record id
$lightbox = (int)$db->insertid();

Initial URL

                                

Initial Description

                                

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

Initial Tags
joomla

Initial Language
PHP