50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
class CmsComments extends ObjectModel {
|
|
|
|
public $id_comment;
|
|
public $id_element;
|
|
public $name;
|
|
public $email;
|
|
public $comments;
|
|
public $published;
|
|
public $date_add;
|
|
public $date_upd;
|
|
|
|
/**
|
|
* @see ObjectModel::$definition
|
|
*/
|
|
public static $definition = array(
|
|
'table' => 'cms_comments',
|
|
'primary' => 'id_comment',
|
|
'fields' => array(
|
|
'published' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
|
'id_element' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
|
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => TRUE),
|
|
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => TRUE),
|
|
'comments' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHTML', 'required' => TRUE),
|
|
|
|
'date_add' => array('type' => self::TYPE_DATE),
|
|
'date_upd' => array('type' => self::TYPE_DATE)
|
|
),
|
|
);
|
|
|
|
public function __construct($id = NULL, $id_lang = NULL, $id_shop = NULL) {
|
|
parent::__construct($id, $id_lang, $id_shop);
|
|
}
|
|
|
|
public static function loadComments($id_element) {
|
|
return Db::getInstance()->executeS('
|
|
SELECT
|
|
`name`,
|
|
`email`,
|
|
`comments`,
|
|
`date_add`
|
|
FROM `'._DB_PREFIX_.self::$definition['table'].'`
|
|
WHERE `id_element` = '.(int)$id_element.
|
|
' AND `published` = 1
|
|
ORDER BY `date_add` ASC'
|
|
);
|
|
}
|
|
}
|