Código:
<?php
//no direct access
defined('_JEXEC') or die('Acceso restringido');
class Organismo
{
private $idorganismo=0;
private $nombre="";
private $pais="";
private $descripcion="";
public function __construct() {
$idorganismo=$_POST['codigo'];
$nombre=$_POST['nombre'];
$pais=$_POST['continente'];
$descripcion=$_POST['informacion'];
$db = JFactory::getDBO();
}
public function crear(){
$query = "INSERT INTO organismos VALUES(" . $idorganismo . ", '" . $nombre . "', '" . $pais . "', '" . $descripcion . "');";
$db->setQuery($query);
return $db->query();
}
public function editar(){
echo $nombre;
$query = "UPDATE organismos SET nombre='" . $nombre . "', continente='" . $pais . "', informacion='" . $descripcion . "' WHERE codigo=". $idorganismo . ";";
$db->setQuery($query);
return $db->query();
}
public function eliminar(){
$query = "DELETE FROM organismos WHERE codigo='" . $idorganismo . "';";
$db->setQuery($query);
return $db->query();
}
}
$input = new JInput;
$event = $input->get('event', '','string');
$res=false;
if($event != "")
{
$org = new Organismo;
if($event == 'new')
$res = $org->crear();
if($event == 'edit')
$res = $org->editar();
if($event == 'del')
$res = $org->eliminar();
}
$layout = $params->get('layout', 'default');
require JModuleHelper::getLayoutPath('mod_catorg', $layout);
?>
Notice: Undefined variable: nombre in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 26
Notice: Undefined variable: nombre in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 27
Notice: Undefined variable: pais in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 27
Notice: Undefined variable: descripcion in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 27
Notice: Undefined variable: idorganismo in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 27
Notice: Undefined variable: db in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 28
Fatal error: Call to a member function setQuery() on a non-object in C:\xampp\htdocs\joomla\modules\mod_catorg\mod_catorg.php on line 28