Created
May 28, 2013 05:10
-
-
Save e06widu/5660628 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| // No direct access to this file | |
| defined('_JEXEC') or die('Restricted access'); | |
| // Include dependancy of the main model form | |
| jimport('joomla.application.component.modelform'); | |
| // import Joomla modelitem library | |
| jimport('joomla.application.component.modelitem'); | |
| // Include dependancy of the dispatcher | |
| jimport('joomla.event.dispatcher'); | |
| /** | |
| * HelloWorld Model | |
| */ | |
| class MyResourceListModeljoinwithus extends JModelForm | |
| { | |
| /** | |
| * @var object item | |
| */ | |
| protected $item; | |
| /** | |
| * Get the data for a new qualification | |
| */ | |
| public function getForm($data = array(), $loadData = true) | |
| { | |
| $app = JFactory::getApplication('site'); | |
| // Get the form. | |
| $form = $this->loadForm('com_myresourcelist.joinwithus', 'joinwithus', array('control' => 'jform', 'load_data' => true),true); | |
| if (empty($form)) { | |
| return false; | |
| } | |
| return $form; | |
| } | |
| //Nwely added method for saving data | |
| public function updItem($data) | |
| { | |
| // set the variables from the passed data | |
| $fname = $data['fname']; | |
| $lname = $data['lname']; | |
| $age = $data['age']; | |
| $city = $data['city']; | |
| $telephone = $data['telephone']; | |
| $email = $data['email']; | |
| $comments = $data['comments']; | |
| // set the data into a query to update the record | |
| $db = $this->getDbo(); | |
| $query = $db->getQuery(true); | |
| $query->clear(); | |
| $db =& JFactory::getDBO(); | |
| $query = "INSERT INTO #__joinwithus ( `id`, `firstname`, `lastname`, `age`, `city`, `telephone`, `email`, `comment`) | |
| VALUES (NULL,'" . $fname . "','" . $lname . "','" . $age . "','" . $city . "','" . $email . "','" . $telephone . "','" . $comments . "')"; | |
| $db->setQuery((string)$query); | |
| if (!$db->query()) { | |
| JError::raiseError(500, $db->getErrorMsg()); | |
| return false; | |
| } else { | |
| return true; | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment