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; }
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; }
function SetCondForResizedImages(&$search, $photo_fld) { global $_image; $search->SetJoins([Image::TABLE => [null, [$photo_fld, Image::ID_FLD]]]); $search->AddClause(CCond(CF(Image::TABLE, $_image->GetFieldByName(Image::IS_RESIZED_FLD)), CVP(1), 'AND')); }