12 const TABLE_NAME =
"Friend";
14 public $IdAccount = 0;
16 public $State = FRIEND_STATE_ACCEPTED;
21 public function __construct($src = null, $stripSlashes =
false) {
25 $this->_loadByRow($src, $stripSlashes);
37 public static function Load ($idAccount, $state = NULL, $limit = null, $offset = null, &$count = null, $returnArray =
false) {
38 if ($state === FRIEND_STATE_REQUEST_PENDING) {
39 $where = sprintf(
"(IdFriend = %d) AND (State = %d)", $idAccount, FRIEND_STATE_REQUEST);
41 $where = sprintf(
"(IdAccount = %d)", $idAccount);
42 if ($state !== NULL) {
43 $where .= sprintf(
" AND (State = %d)", $state);
46 return self::_load(self::GetTableName(__CLASS__), ($returnArray ?
"" : __CLASS__), $where, NULL, $limit, $offset, $count);
56 $query = sprintf(
"REPLACE INTO %s (IdAccount, IdFriend, State) VALUES (%d, %d, %d)",
57 self::GetTableName(__CLASS__),
61 return $Database->Query($query);
70 if ($this->IdAccount < 1 || $this->IdFriend < 1)
72 return $this->_Delete(self::GetTableName(__CLASS__), sprintf(
"IdAccount = %d AND IdFriend = %d", $this->IdAccount, $this->IdFriend));
83 if ($idUser1 > 0 && $idUser2 > 0) {
84 $where = sprintf(
"(IdAccount = %d AND IdFriend = %d) OR (IdAccount = %d AND IdFriend = %d)", $idUser1, $idUser2, $idUser2, $idUser1);
86 return $self->_Delete(self::GetTableName(__CLASS__), $where);
static DeleteBoth($idUser1, $idUser2)
static Load($idAccount, $state=NULL, $limit=null, $offset=null, &$count=null, $returnArray=false)
__construct($src=null, $stripSlashes=false)