本文整理汇总了PHP中SQL::MakeJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::MakeJoin方法的具体用法?PHP SQL::MakeJoin怎么用?PHP SQL::MakeJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::MakeJoin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetSelectValues
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);
}
示例2: GetJoins
public function GetJoins()
{
if ($this->isChangeJoin) {
$this->joins = SQL::MakeJoin($this->table, $this->joinFields);
$this->isChangeJoin = false;
}
return $this->joins;
}
示例3: GenQueryForList
private function GenQueryForList($user_id, $limit, $start = 0)
{
global $_user, $_place;
$fields = SQL::GetListFieldsForSelect(array_merge(SQL::PrepareFieldsForSelect(static::TABLE, [$this->idField, $this->GetFieldByName(static::HEAD_FLD), $this->GetFieldByName(static::CREATION_DATE_FLD), $this->GetFieldByName(static::DUE_DATE_FLD), $this->GetFieldByName(static::TYPE_FLD), $this->GetFieldByName(static::DESCRIPTION_FLD)]), SQL::PrepareFieldsForSelect(User::TABLE, [$_user->idField, $_user->GetFieldByName(User::NAME_FLD), $_user->GetFieldByName(User::SURNAME_FLD), $_user->GetFieldByName(User::PHOTO_FLD)]), SQL::PrepareFieldsForSelect(Place::TABLE, [$_place->GetFieldByName(Place::TYPE_FLD), $_place->GetFieldByName(Place::NUMBER_FLD)])));
return sprintf('SELECT %s FROM %s %s WHERE %s = %s %s ORDER BY %s DESC LIMIT %d, %d', $fields, static::TABLE, SQL::MakeJoin(static::TABLE, [User::TABLE => [null, [static::OWNER_FLD, User::ID_FLD]], Place::TABLE => [null, [static::PLACE_FLD, Place::ID_FLD]]]), $this->ToTblNm(static::TYPE_FLD), '%d', !empty($user_id) ? sprintf('AND %s = ?', $_user->ToTblNm(User::ID_FLD)) : '', $this->ToTblNm(static::CREATION_DATE_FLD), $start, $limit);
}
示例4: ImageSelectSQL
function ImageSelectSQL($th, $entity, $field)
{
global $_image;
return sprintf("IFNULL((SELECT GROUP_CONCAT(%s) FROM %s %s WHERE %s GROUP BY %s), '') as %s", $entity->ToTblNm($entity::PHOTO_FLD), $entity::TABLE, SQL::MakeJoin($entity::TABLE, [Image::TABLE => [null, [$entity::PHOTO_FLD, Image::ID_FLD]]]), (new Clause(CCond(CF($entity::TABLE, $entity->GetFieldByName($field)), CF($th::TABLE, $th->GetFieldByName($th::ID_FLD))), CCond(CF(Image::TABLE, $_image->GetFieldByName(Image::IS_RESIZED_FLD)), CVS(1), 'AND')))->GetClause(), $th->ToTblNm($th::ID_FLD), $th->ToPrfxNm($th::PHOTOS_FLD));
}