vabbè cercherò di fornire + infrmazioni possibile... magari una mano qualcuno può darmela...
allora ho cercato di rispettare l'architetture MVC il più possibile, quindi ho il form nel template:
Codice PHP:
<?php defined('_JEXEC') or die('Restricted access'); ?>
<h1><?php echo $this->title; ?></h1>
<form action="<?php $this->save(); ?>" method="post" name="adminForm" id="adminForm">
User: <input type="text" name="daid" value="" />
Msg: <input class="text_area" type="text" name="msg" id="gmsg" size="32" maxlength="250" value="<?php echo $this->messy->mess;?>" />
<input type="hidden" name="option" value="com_messy" />
<input type="hidden" name="id" value="<?php echo $this->messy->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="messy" />
<input type="submit" name="invia" />
</form>
dove:
Codice PHP:
$this->save()
fa riferimento al view:
Codice PHP:
function save ()
{
$this->save();
}
dove:
Codice PHP:
$this->save()
fa riferimento al controller:
Codice PHP:
function save()
{
$model = $this->getModel('messy');
if ($model->store()) {
$msg = JText::_( 'Salvato' );
} else {
$msg = JText::_( 'Impossibile salvare il messaggio' );
}
// Check the table in so it can be edited.... we are done with it anyway
$link = 'index.php?option=com_messy';
$this->setRedirect($link, $msg);
}
dove
Codice PHP:
$model = $this->getModel('messy');
fa riferimento ad un file che gestisce la query:
Codice PHP:
class TableMessy extends JTable
{
/**
* Primary Key
*
* @var int
*/
var $id = null;
/**
* @var string
*/
var $daid = null;
/**
* @var string
*/
var $aid = null;
/**
* @var string
*/
var $msg = null;
/**
* Constructor
*
* @param object Database connector object
*/
function TableMessy( &$db ) {
parent::__construct('#__messy_msg', 'id', $db);
}
}
e invece:
Codice PHP:
$model->store()
fa riferimento ad un model aggiuntivo:
Codice PHP:
function store()
{
$row =& $this->getTable();
$data = JRequest::get( 'post' );
// Bind the form fields to the messy table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the messy record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the web link table to the database
if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return true;
}
il procedimento non funziona, non appena lo provo, apache smette di funzionare.
perchèèè