Combu Server  3.1.1
PHP API Documentation
NewsletterLog.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
10 class NewsletterLog extends DataClass {
11 
12  const TABLE_NAME = "NewsletterLog";
13 
14  public $Id = 0;
15  public $IdNewsletter = 0;
16  public $IdAccount = 0;
17  public $Sent = 0;
18  public $DateCreation = "";
19  public $Message = "";
20 
24  public function __construct($src = null, $stripSlashes = false) {
25  global $Database;
26  if ($src == null)
27  return;
28  if (is_array($src)) {
29  // Load by array
30  $this->_loadByRow($src, $stripSlashes);
31  } else if (is_numeric($src) && intval($src) > 0) {
32  // Load by Id
33  $this->_loadFilter(self::GetTableName(__CLASS__), "Id = " . intval($src));
34  }
35  }
36 
47  public static function Load ($idNewsletter, $limit = null, $offset = null, &$count = null, $returnArray = false) {
48  $where = sprintf("IdNewsletter = %d", $idNewsletter);
49  return self::_load(self::GetTableName(__CLASS__), ($returnArray ? "" : __CLASS__), $where, NULL, $limit, $offset, $count);
50  }
51 
57  public function Save() {
58  global $Database;
59  if ($this->Id > 0)
60  return FALSE;
61  $this->DateCreation = date("Y-m-d H:i:s");
62  $query = sprintf("INSERT INTO %s (IdNewsletter, IdAccount, Sent, DateCreation, Message) VALUES (%d, %d, %d, %s, '%s')",
63  self::GetTableName(__CLASS__),
64  $this->IdNewsletter,
65  $this->IdAccount,
66  $this->Sent,
67  $Database->EscapeDate($this->DateCreation),
68  $Database->Escape($this->Message));
69  if ($Database->Query($query)) {
70  if ($this->Id < 1)
71  $this->Id = $Database->InsertedId();
72  return TRUE;
73  }
74  return FALSE;
75  }
76 
82  public function Delete() {
83  if ($this->Id < 1)
84  return FALSE;
85  return $this->_Delete(self::GetTableName(__CLASS__), "Id = " . $this->Id);
86  }
87 }
static Load($idNewsletter, $limit=null, $offset=null, &$count=null, $returnArray=false)
__construct($src=null, $stripSlashes=false)
Definition: Account.php:3