// Set $definition in ObjectModel classes for modules

This commit is contained in:
rMalie
2011-12-30 15:37:57 +00:00
parent 15b123aed1
commit 84f08cb76b
8 changed files with 157 additions and 249 deletions
+16 -18
View File
@@ -38,24 +38,22 @@ class LoyaltyModule extends ObjectModel
public $date_add;
public $date_upd;
protected $fieldsRequired = array('id_customer', 'points');
protected $fieldsValidate = array('id_loyalty_state' => 'isInt', 'id_customer' => 'isInt', 'id_cart_rule' => 'isInt', 'id_order' => 'isInt', 'points' => 'isInt');
protected $table = 'loyalty';
protected $identifier = 'id_loyalty';
public function getFields()
{
$this->validateFields();
$fields['id_loyalty_state'] = (int)$this->id_loyalty_state;
$fields['id_customer'] = (int)$this->id_customer;
$fields['id_order'] = (int)$this->id_order;
$fields['id_cart_rule'] = (int)$this->id_cart_rule;
$fields['points'] = (int)$this->points;
$fields['date_add'] = pSQL($this->date_add);
$fields['date_upd'] = pSQL($this->date_upd);
return $fields;
}
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'loyalty',
'primary' => 'id_loyalty',
'fields' => array(
'id_loyalty_state' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'points' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
)
);
public function save($nullValues = false, $autodate = true)
{
+12 -24
View File
@@ -33,31 +33,19 @@ class LoyaltyStateModule extends ObjectModel
public $name;
public $id_order_state;
protected $fieldsValidate = array('id_order_state' => 'isInt');
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 128);
protected $fieldsValidateLang = array('name' => 'isGenericName');
protected $table = 'loyalty_state';
protected $identifier = 'id_loyalty_state';
public function getFields()
{
$this->validateFields();
$fields['id_order_state'] = (int)($this->id_order_state);
return $fields;
}
/**
* Check then return multilingual fields for database interaction
*
* @return array Multilingual fields
*/
public function getTranslationsFieldsChild()
{
$this->validateFieldsLang();
return $this->getTranslationsFields(array('name'));
}
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'loyalty_state',
'primary' => 'id_loyalty_state',
'fields' => array(
'id_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
),
);
public static function getDefaultId() { return 1; }
public static function getValidationId() { return 2; }