public function SetSelectValues() { $fields = array(); $this->CheckSearch(); switch ($this->samplingScheme) { case static::INIT_SCHEME: $fields = SQL::PrepareFieldsForSelect(static::TABLE, [$this->idField, $this->GetFieldByName(static::NUMBER_FLD), $this->GetFieldByName(static::POLYGON_FLD), $this->GetFieldByName(static::TYPE_FLD)]); $this->initFields = $fields; $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::FLOOR_FLD)), CVP($this->GetFieldByName(static::FLOOR_FLD)->GetValue()), cAND))->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::HOSTEL_FLD)), CVP($this->GetFieldByName(static::HOSTEL_FLD)->GetValue()), cAND, opEQ)); break; case static::AVAILABLE_SCHEME: // SELECT // places.id as places_id, // places.number as places_number, // places.polygon as places_polygon, // places.place_type as places_place_type // FROM places // WHERE // places.floor = 1 AND // ( // ( // places.place_type = 1 AND // places.number = (SELECT users.room FROM users INNER JOIN sessions ON sessions.user_id = users.id WHERE sessions.sid = '153382469192f1') // ) // OR places.place_type <> 1 // ) $fields = $this->initFields; global $_user, $_session; $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::TYPE_FLD)), CVP(1), cAND, opEQ, '(('))->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::NUMBER_FLD)), CVS('(' . SQL::SimpleQuerySelect($_user->ToTblNm(User::ROOM_FLD), sprintf('%s %s', User::TABLE, SQL::MakeJoin(User::TABLE, [Session::TABLE => [null, [User::ID_FLD, Session::USER_FLD]]])), new Clause(CCond(CF(Session::TABLE, $_session->GetFieldByName(Session::SID_FLD)), CVS(sprintf("'%s'", $_SESSION['sid']))))) . ')'), cAND, opEQ, null, ')'))->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::TYPE_FLD)), CVP(1), cOR, opNE, null, ')')); break; } $this->selectFields = SQL::GetListFieldsForSelect($fields); }
private function CheckPermissions($login, $pass) { $this->CreateSearch(); $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::LOGIN_FLD)), CVP($login))); $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::PASS_FLD)), new MD5View(CVP($pass)), 'AND')); $adminInfo = $this->GetPart(); return !empty($adminInfo); }
public function GetBySID($sid) { $this->CheckSearch(); $this->selectFields = SQL::GetListFieldsForSelect(SQL::PrepareFieldsForSelect(static::TABLE, [$this->idField, $this->GetFieldByName(static::USER_FLD)])); $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::SID_FLD)), CVP($sid), cAND)); $result = $this->GetPart(); $this->search->RemoveClause(); return $result; }
function CA($f) { P::Q(); $j = P::$c->CE(); $k = array(); foreach ($j as $l) { $m = CF($l, $f); if ($m < 4) { $k[] = $l; } } return $k; }
public function Delete($id) { parent::Delete($id); $this->DeleteImg($id); global $db; try { $db->link->beginTransaction(); $query = SQL::SimpleQuerySelect($this->ToTblNm(static::ID_FLD), static::TABLE, new Clause(CCond(CF(static::TABLE, $this->GetFieldByName(static::IS_RESIZED_FLD)), CVS(0)))); $sample = $db->Query($query); $db->Query('DELETE FROM ' . static::TABLE . ' WHERE ' . static::IS_RESIZED_FLD . ' = 0'); foreach ($sample as &$set) { $this->DeleteImg($set[static::ID_FLD]); } $db->link->commit(); } catch (DBException $e) { $db->link->rollback(); throw new Exception($e->getMessage()); } }
public function GetById($id) { $this->CheckSearch(); $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::ID_FLD)), CVP($id), 'AND')); $result = $this->GetAll(); $this->search->RemoveClause(); return !empty($result[0]) ? $result[0] : []; }
public function GetNewInfo($lastUpdatedDate) { $this->lastUpdatedDate = $lastUpdatedDate; $result['deleted'] = $this->SetSamplingScheme(static::NEW_DELETTION_SCHEME)->GetAll(); $this->search = new Search(static::TABLE, new Clause(CCond(CF(static::TABLE, $this->GetFieldByName(static::UPDATED_DATE_FLD)), CVP($lastUpdatedDate), null, opGE))); $result['created'] = $this->SetSamplingScheme(static::INIT_SCHEME)->GetAll(); return $result; }
public function GetByLogin($login) { $this->CheckSearch(); $this->search->AddClause(CCond(CF(static::TABLE, $this->GetFieldByName(static::LOGIN_FLD)), CVP($login), cAND)); $result = $this->GetPart(); $this->search->RemoveClause(); return $result; }