Jump to content

Crear Clase que herede de ObjectModel


Tito Samuel

Recommended Posts

Hola, estoy intentando crear una clase que hereda de ObjectModel, pero al hacer un New, no se carga la pagina lo cual indica que hay un error, les indico, e instanciado la clase de las siguientes formas:

$cupo = new Cupo();
$cupo = new Cupo($id);

Pero ninguna funciona, aqui les dejo el codigo de la clase:

class        Cupo extends ObjectModel
{    
   /** @var integer Currency id */
   public         $id_currency;

   /** @var string Secure key */
   public        $secure_key;

   /** @var string Payment method id */
   public         $payment;

   /** @var string Payment module */
   public         $module;

   /** @var float Total del cupo */
   public         $total_cupo;

   /** @var float Total a comprar */
   public         $total_compra;

   /** @var string Invoice creation date */
   public         $invoice_date;

   /** @var string Delivery creation date */
   public         $delivery_date;

   /** @var boolean Order validity (paid and not canceled) */
   public         $valid;

   /** @var string Object last modification date */
   public         $date_upd;

   protected $tables = array ('cupo');

   protected    $fieldsRequired = array('id_currency', 'payment', 'total_compra');
   protected    $fieldsSize = array('payment' => 32);
   protected    $fieldsValidate = array(        
       'id_currency' => 'isUnsignedId',
       'secure_key' => 'isMd5',
       'payment' => 'isGenericName',        
       'total_cupo' => 'isPrice',
       'total_compra' => 'isPrice'
       );

   /* MySQL does not allow 'order' for a table name */
   protected     $table = 'cupo';
   protected     $identifier = 'id_customer';

   public function getFields()
   {
       parent::validateFields();

       $fields['secure_key'] = pSQL($this->secure_key);
       $fields['payment'] = pSQL($this->payment);
       $fields['module'] = pSQL($this->module);
       $fields['total_cupo'] = floatval($this->total_cupo);
       $fields['total_compra'] = floatval($this->total_compra);        
       $fields['invoice_date'] = pSQL($this->invoice_date);        
       $fields['valid'] = intval($this->valid) ? 1 : 0;
       $fields['date_upd'] = pSQL($this->date_upd);

       return $fields;
   }    

   public function isLogable()
   {
       return $this->valid;
   }    

   /**
    * Get customer cupo total
    *     
    * @return array Customer cupo
    */
   static public function getCustomerCupo()
   {
       $result = Db::getInstance()->getRow('
       SELECT monto as cp
       FROM `'._DB_PREFIX_.'cupo`
       WHERE `id_customer` = '.intval($this->id));

       return isset($result['cp']) ? $result['cp'] : 0;
   }

   /**
    * Add nuevo registro para cupo por primera vez
    *
    * @param double $monto valor a regarcar en cupo
    * @return boolean Query sucess or not
    */
   public function    addFirstCupo($monto)
   {
       return Db::getInstance()->AutoExecute(_DB_PREFIX_.'cupot', array('id_cupo' => intval($this->id), 'monto' => doubleval($monto), 'date_add' => pSql(date('Y-m-d H:i:s')), 'INSERT');
   }

}



Gracias de antemano por su ayuda

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...