Created
January 20, 2012 21:12
-
-
Save fititnt/1649631 to your computer and use it in GitHub Desktop.
Visão salvando em mais de uma tabela
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// admin / controllers / helloworld.php | |
jimport('joomla.application.component.controllerform'); | |
class HelloWorldControllerHelloWorld extends JControllerForm | |
{ | |
//... | |
public function save($key = null, $urlVar = null) { | |
// Check for request forgeries. | |
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); | |
$data = JRequest::getVar('jform', array(), 'post', 'array');//Pega o jform(ou use outro) | |
//... faz o que tem que fazer com o $jform | |
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/com_component/tables'); | |
$row = & JTable::getInstance('table', 'Table'); | |
//Check if can save data | |
if (!$row->bind($data)) { | |
return JError::raiseWarning(500, $row->getError()); | |
} | |
//Save Data | |
if (!$row->store()) { | |
JError::raiseError(500, $row->getError()); | |
} | |
//$row->id;//Last id | |
//Load Data | |
if (!$row->load($id)) { | |
return JError::raiseWarning(500, $row->getError()); | |
} | |
$row->delete($id); | |
JRequest::setVar('jform', $data, 'post', 'array');//Re-seta a $jform no JRerequest | |
parent::save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment