12 const TABLE_NAME =
"News";
16 public $IdAdminAccount = 0;
17 public $PublishDate =
"";
25 public function __construct($src = null, $stripSlashes =
false) {
31 $this->_loadByRow($src, $stripSlashes);
32 }
else if (is_numeric($src) && intval($src) > 0) {
34 $this->_loadFilter(self::GetTableName(__CLASS__),
"Id = " . intval($src));
48 public static function Load ($idApp = 0, $limit = null, $offset = null, &$count = null, $returnArray =
false) {
51 if ($AppId->IsValid()) {
52 $where = sprintf(
"(IdApp = 0 OR IdApp = %d)", $AppId->Id);
55 $where = sprintf(
"(IdApp = %d)", $idApp);
57 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), $where,
"PublishDate DESC", $limit, $offset, $count);
68 $query = sprintf(
"UPDATE %s SET Subject = '%s', Message = '%s', Url = '%s' WHERE Id = %d",
69 self::GetTableName(__CLASS__),
70 $Database->Escape($this->Subject),
71 $Database->Escape($this->Message),
72 $Database->Escape($this->Url),
75 $this->PublishDate = Utils::GetCurrentDateTimeFormat();
76 $query = sprintf(
"INSERT INTO %s (IdApp, PublishDate, IdAdminAccount, Subject, Message, Url) VALUES (%d, %s, %d, '%s', '%s', '%s')",
77 self::GetTableName(__CLASS__),
79 $Database->EscapeDate($this->PublishDate),
80 $this->IdAdminAccount,
81 $Database->Escape($this->Subject),
82 $Database->Escape($this->Message),
83 $Database->Escape($this->Url));
85 if ($Database->Query($query)) {
87 $this->Id = $Database->InsertedId();
101 return $this->_Delete(self::GetTableName(__CLASS__),
"Id = " . $this->Id);
__construct($src=null, $stripSlashes=false)
static Load($idApp=0, $limit=null, $offset=null, &$count=null, $returnArray=false)