Aggiungo anche i codici del model
file alunnis.php
class StagesModelAlunnis extends JModel
{
/**
* ARRAY
*/
var $_alunni;
/**
* imposto la query
*/
function _buildQuery($table)
{
$query = ' SELECT * '
. ' FROM '.$table;
return $query;
}
/**
* Recupero dei dati
* @return array Array of objects containing the data from the database
*/
function getAlunni()
{
// ricarico i dati
if (empty( $this->_alunni ))
{
$query = $this->_buildQuery('#__Alunni');
$this->_alunni = $this->_getList( $query );
}
return $this->_alunni;
}
}
e il file alunni.php
class StagesModelAlunni extends JModel
{
/**
* Constructor that retrieves the ID from the request
*
* @access public
* @return void
*/
function __construct()
{
parent::__construct();
$array = JRequest::getVar('cid', 0, '', 'array');
$this->setId((int)$array[0]);
}
/**
* Method to set the Alunni identifier
*
* @access public
* @param int Alunni identifier
* @return void
*/
function setId($CodAlu)
{
// Set id and wipe data
$this->_CodAlu = $CodAlu;
$this->_alunni= null;
}
/**
* Method to get Alunni
* @return object with data
*/
function &getAlunni()
{
// Load the data
if (empty( $this->_alunni )) {
$query = ' SELECT * FROM #__Alunni '.
' WHERE CodAlu = '.$this->_CodAlu;
$this->_db->setQuery( $query );
$this->_alunni = $this->_db->loadObject();
}
if (!$this->_alunni) {
$this->_alunni= new stdClass();
$this->_alunnI->CodAlu = 0;
$this->_alunni->CodCl = 0;
$this->_alunni->Nome = null;
$this->_alunni->Cogn = null;
$this->_alunni->DataNa = null;
$this->_alunni->Via = null;
$this->_alunni->Loc = null;
$this->_alunni->Prov = null;
$this->_alunni->NumTel = null;
$this->_alunni->NumCell = null;
$this->_alunni->Mail = null;
}
return $this->_alunni;
}
/**
* Method to store a record
*
* @access public
* @return boolean True on success
*/
function store()
{
$row =& $this->getTable('alunni');
$data = JRequest::get( 'post' );
// Bind the form fields to the hello table
if (!$row->bind($data))
{
//JError::raiseError(500, 'Error binding data');
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the hello 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( $row->getErrorMsg() );
return false;
}
return true;
}
/**
* Method to delete record(s)
*
* @access public
* @return boolean True on success
*/
function delete()
{
$cids = JRequest::getVar( 'cid', array(0), 'post', 'array' );
$row =& $this->getTable('Alunni');
if (count( $cids )) {
foreach($cids as $cid) {
if (!$row->delete( $cid )) {
$this->setError( $row->getErrorMsg() );
return false;
}
}
}
return true;
}
}
boh non capisco xkè alunnis.php riesce ad eseguirmelo correttamente.mentre la delete() e la store() contenute in alunni.php non le fa....:-(