phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla - MVC: Saving Data for Back End

Tag: joomla, MVC, pattern, component   Category: PHP Framework
post: 07 Feb 2008 read: 1,577


Joomla Back End MVC Step by Step Tutorial - Part 7: After create form at previous post, now we add saving function. Open your "controller.php", Add following code:

joomla mvc saving data at back-end


  function save()
  {
  	global $option;
	$row =& JTable::getInstance('hello', 'Table');
	if(!$row->bind(JRequest::get('post')))
	{
		JError::raiseError(500, $row->getError() );
	}
	$row->message = JRequest::getVar( 'message', '','post', 'string', JREQUEST_ALLOWRAW );
	
	if(!$row->store()){
		JError::raiseError(500, $row->getError() );
	}
	
	switch($this->_task)
	{
		case 'apply':
			$msg  = 'Change Saved';
			$link = 'index.php?option='.$option.
					'&task=edit&cid[]='.$row->id;
			break;
		case 'save':
			$msg  = 'Saved';
			$link = 'index.php?option='.$option;
			break;
		default:
		
	}
	$this->setRedirect($link, $msg);
  }
Now, try it.


Series this article:
Joomla - MVC: Reorganizing Back End Code
Joomla - MVC: Creating Controller and Model for Back End
Joomla - MVC: Creating View for Back End
Joomla - MVC: Adding Pagination for Back End
Joomla - MVC: Adding Element Paginating for Back End
Joomla - MVC: Creating Form Input Data for Back-End
Joomla - MVC: Saving Data for Back End
Joomla - MVC: Editing Data for Back-End
Joomla - MVC: Adding Delete Function at Back-End
Joomla - MVC: Controlling Publish State for Back-End

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
SMS : Sending SMS with PHP and ActiveXperts (Part 1)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting