本文整理汇总了PHP中SQLSelect类的典型用法代码示例。如果您正苦于以下问题:PHP SQLSelect类的具体用法?PHP SQLSelect怎么用?PHP SQLSelect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQLSelect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: augmentSQL
/**
* Update any requests to limit the results to the current site
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = NULL)
{
if (Subsite::$disable_subsite_filter) {
return;
}
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
if ($query->filtersOnID()) {
return;
}
$regexp = '/^(.*\\.)?("|`)?SubsiteID("|`)?\\s?=/';
foreach ($query->getWhereParameterised($parameters) as $predicate) {
if (preg_match($regexp, $predicate)) {
return;
}
}
try {
$subsiteID = (int) Subsite::currentSubsiteID();
$froms = $query->getFrom();
$froms = array_keys($froms);
$tableName = array_shift($froms);
if ($tableName != 'SiteConfig') {
return;
}
$query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
} catch (UnexpectedValueException $e) {
// No subsites exist yet
}
}
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:31,代码来源:SiteConfigSubsites.php
示例2: augmentSQL
/**
* Update any requests to limit the results to the current site
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = NULL)
{
if (Subsite::$disable_subsite_filter) {
return;
}
if ($dataQuery->getQueryParam('Subsite.filter') === false) {
return;
}
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
// if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
if ($query->filtersOnID()) {
return;
}
if (Subsite::$force_subsite) {
$subsiteID = Subsite::$force_subsite;
} else {
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
else */
$subsiteID = (int) Subsite::currentSubsiteID();
}
// The foreach is an ugly way of getting the first key :-)
foreach ($query->getFrom() as $tableName => $info) {
// The tableName should be SiteTree or SiteTree_Live...
if (strpos($tableName, 'SiteTree') === false) {
break;
}
$query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
break;
}
}
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:33,代码来源:SiteTreeSubsites.php
示例3: augmentSQL
/**
* Update any requests to limit the results to the current site
*/
public function augmentSQL(SQLSelect $query)
{
if (Subsite::$disable_subsite_filter) {
return;
}
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
if ($query->filtersOnID()) {
return;
}
$regexp = '/^(.*\\.)?("|`)?SubsiteID("|`)?\\s?=/';
foreach ($query->getWhereParameterised($parameters) as $predicate) {
if (preg_match($regexp, $predicate)) {
return;
}
}
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
else */
$subsiteID = (int) Subsite::currentSubsiteID();
$froms = $query->getFrom();
$froms = array_keys($froms);
$tableName = array_shift($froms);
if ($tableName != 'SiteConfig') {
return;
}
$query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
}
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:29,代码来源:SiteConfigSubsites.php
示例4: buildLimitFragment
/**
* Return the LIMIT clause ready for inserting into a query.
*
* @param SQLSelect $query The expression object to build from
* @param array $parameters Out parameter for the resulting query parameters
* @return string The finalised limit SQL fragment
*/
public function buildLimitFragment(SQLSelect $query, array &$parameters)
{
$nl = $this->getSeparator();
// Ensure limit is given
$limit = $query->getLimit();
if (empty($limit)) {
return '';
}
// For literal values return this as the limit SQL
if (!is_array($limit)) {
return "{$nl}LIMIT {$limit}";
}
// Assert that the array version provides the 'limit' key
if (!array_key_exists('limit', $limit) || $limit['limit'] !== null && !is_numeric($limit['limit'])) {
throw new InvalidArgumentException('SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: ' . var_export($limit, true));
}
$clause = "{$nl}";
if ($limit['limit'] !== null) {
$clause .= "LIMIT {$limit['limit']} ";
} else {
$clause .= "LIMIT -1 ";
}
if (isset($limit['start']) && is_numeric($limit['start']) && $limit['start'] !== 0) {
$clause .= "OFFSET {$limit['start']}";
}
return $clause;
}
开发者ID:helpfulrobot,项目名称:silverstripe-sqlite3,代码行数:34,代码来源:SQLite3QueryBuilder.php
示例5: LoadFromDB
function LoadFromDB() {
global $POSTS_PER_PAGE;
$s = new SQLSelect();
$s->AddTable("bbs_topics");
$s->AddWhere("bbs_topics.id=".$this->id);
$this->topic = SQLLib::SelectRow($s->GetQuery());
if(!$this->topic) return false;
$s = new SQLSelect();
$s->AddField("count(*) as c");
$s->AddTable("bbs_posts");
$s->AddWhere("bbs_posts.topic=".$this->id);
$this->postcount = SQLLib::SelectRow($s->GetQuery())->c;
$s = new BM_Query();
$s->AddTable("bbs_posts");
$s->AddField("bbs_posts.id as id");
$s->AddField("bbs_posts.post as post");
$s->AddField("bbs_posts.added as added");
$s->attach(array("bbs_posts"=>"author"),array("users as user"=>"id"));
$s->AddWhere("bbs_posts.topic=".$this->id);
//$s->SetLimit( $POSTS_PER_PAGE, (int)(($this->page - 1)*$POSTS_PER_PAGE) );
$this->paginator = new PouetPaginator();
$this->paginator->SetData( "topic.php?which=".$this->id, $this->postcount, $POSTS_PER_PAGE, $_GET["page"] );
$this->paginator->SetLimitOnQuery( $s );
$this->posts = $s->perform();
$this->title = _html($this->topic->topic);
}
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:32,代码来源:topic.php
示例6: getMap
public function getMap()
{
$this->getDimensions();
if (empty($this->map)) {
$sel = new SQLSelect($this->table);
$res = $sel->execute();
$this->map = parallelToAssoc($res[strtoupper($this->idfields[0])], $res[strtoupper($this->idfields[1])]);
}
return $this->map;
}
开发者ID:hughlaura,项目名称:php_oracle_handytools,代码行数:10,代码来源:recordMap.class.php
示例7: getPossLanguages
public function getPossLanguages()
{
if (empty($this->posslanguages)) {
$getl = new SQLSelect("translation_language");
$getl->fetchas = "row";
$res = $getl->execute();
$this->posslanguages = $res;
}
return $this->posslanguages;
}
开发者ID:hughlaura,项目名称:php_oracle_handytools,代码行数:10,代码来源:SurveyTextElement.class.php
示例8: processFields
public function processFields()
{
if (!isset($this->fields["language_keycode"]["options"])) {
$opsel = new SQLSelect("translation_language");
$opsel->selectfields = array("id" => "keycode", "label" => "name_def");
$opsel->fetchas = "row";
$res = $opsel->execute();
$options = $res;
$this->fields["language_keycode"]["options"] = $options;
}
}
开发者ID:hughlaura,项目名称:php_oracle_handytools,代码行数:11,代码来源:Translation.class.php
示例9: parseLimit
/**
* Extracts the limit and offset from the limit clause
*
* @param SQLSelect $query
* @return array Two item array with $limit and $offset as values
* @throws InvalidArgumentException
*/
protected function parseLimit(SQLSelect $query)
{
$limit = '';
$offset = '0';
if (is_array($query->getLimit())) {
$limitArr = $query->getLimit();
if (isset($limitArr['limit'])) {
$limit = $limitArr['limit'];
}
if (isset($limitArr['start'])) {
$offset = $limitArr['start'];
}
} else {
if (preg_match('/^([0-9]+) offset ([0-9]+)$/i', trim($query->getLimit()), $matches)) {
$limit = $matches[1];
$offset = $matches[2];
} else {
//could be a comma delimited string
$bits = explode(',', $query->getLimit());
if (sizeof($bits) > 1) {
list($offset, $limit) = $bits;
} else {
$limit = $bits[0];
}
}
}
return array($limit, $offset);
}
开发者ID:helpfulrobot,项目名称:silverstripe-mssql,代码行数:35,代码来源:MSSQLQueryBuilder.php
示例10: find_old_page
/**
* Attempt to find an old/renamed page from some given the URL as an array
*
* @param array $params The array of URL, e.g. /foo/bar as array('foo', 'bar')
* @param SiteTree $parent The current parent in the recursive flow
* @param boolean $redirect Whether we've found an old page worthy of a redirect
*
* @return string|boolean False, or the new URL
*/
public static function find_old_page($params, $parent = null, $redirect = false)
{
$parent = is_numeric($parent) ? SiteTree::get()->byId($parent) : $parent;
$params = (array) $params;
$URL = rawurlencode(array_shift($params));
if (empty($URL)) {
return false;
}
if ($parent) {
$page = SiteTree::get()->filter(array('ParentID' => $parent->ID, 'URLSegment' => $URL))->First();
} else {
$page = SiteTree::get()->filter(array('URLSegment' => $URL))->First();
}
if (!$page) {
// If we haven't found a candidate, lets resort to finding an old page with this URL segment
$oldFilter = array('"SiteTree_versions"."URLSegment"' => $URL, '"SiteTree_versions"."WasPublished"' => true);
if ($parent) {
$oldFilter[] = array('"SiteTree_versions"."ParentID"' => $parent->ID);
}
$query = new SQLSelect('"RecordID"', '"SiteTree_versions"', $oldFilter, '"LastEdited" DESC', null, null, 1);
$record = $query->execute()->first();
if ($record) {
$page = SiteTree::get()->byID($record['RecordID']);
$redirect = true;
}
}
if ($page && $page->canView()) {
if (count($params)) {
// We have to go deeper!
$ret = self::find_old_page($params, $page, $redirect);
if ($ret) {
// A valid child page was found! We can return it
return $ret;
} else {
// No valid page found.
if ($redirect) {
// If we had some redirect to be done, lets do it. imagine /foo/action -> /bar/action, we still want this redirect to happen if action isn't a page
return $page->Link() . implode('/', $params);
}
}
} else {
// We've found the final, end all, page.
return $page->Link();
}
}
return false;
}
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:56,代码来源:OldPageRedirector.php
示例11: augmentSQL
/**
* Update any requests to limit the results to the current site
*/
public function augmentSQL(SQLSelect $query)
{
if (Subsite::$disable_subsite_filter) {
return;
}
// If you're querying by ID, ignore the sub-site - this is a bit ugly... (but it was WAYYYYYYYYY worse)
//@TODO I don't think excluding if SiteTree_ImageTracking is a good idea however because of the SS 3.0 api and ManyManyList::removeAll() changing the from table after this function is called there isn't much of a choice
$from = $query->getFrom();
if (isset($from['SiteTree_ImageTracking']) || $query->filtersOnID()) {
return;
}
$subsiteID = (int) Subsite::currentSubsiteID();
// The foreach is an ugly way of getting the first key :-)
foreach ($query->getFrom() as $tableName => $info) {
$where = "\"{$tableName}\".\"SubsiteID\" IN (0, {$subsiteID})";
$query->addWhere($where);
break;
}
$sect = array_values($query->getSelect());
$isCounting = strpos($sect[0], 'COUNT') !== false;
// Ordering when deleting or counting doesn't apply
if (!$isCounting) {
$query->addOrderBy("\"SubsiteID\"");
}
}
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:28,代码来源:FileSubsites.php
示例12: build_query
public function build_query()
{
$setstring = "";
// If insertIfAbsent is set, check for the row
if ($this->insertIfAbsent) {
$sel = new SQLSelect($this->table, $this->schema);
$sel->selectfields[] = "1";
$sel->wherearray = $this->selectors;
$val = $sel->execute();
if ($val == NULL || empty($val) || $val[1] == array()) {
$ins = new SQLInsert($this->table, $this->values);
$q = $ins->build_query();
$this->query = $q;
return $this->query;
}
}
// Perform the UPDATE
foreach ($this->values as $key => $value) {
// Skip selectors
if (isset($this->selectors[$key])) {
continue;
}
// Build 'SET' string
if ($setstring != "") {
$setstring .= ",";
}
$setstring .= $key . "=" . dbize($value, $this->get_column_datatype($key));
}
if ($setstring != "") {
$setstring = " SET " . $setstring;
}
// Add selectors to WHERE clause
foreach ($this->selectors as $key => $value) {
$this->wherefields[] = "{$key} = " . dbize($value, $this->get_column_datatype($key));
}
$wherestring = $this->wherefields_to_string();
if ($setstring != "" && $wherestring != "") {
$query = "UPDATE " . $this->table_with_schema() . $setstring . $wherestring;
$this->query = $query;
}
return $this->query;
}
开发者ID:hughlaura,项目名称:php_oracle_handytools,代码行数:42,代码来源:SQLUpdate.class.php
示例13: LoadFromDB
function LoadFromDB() {
$s = new SQLSelect();
$this->group = PouetGroup::Spawn($this->id);
$this->addeduser = PouetUser::Spawn($this->group->addedUser);
// not to boast or anything, but this is fucking beautiful.
$sub = new SQLSelect();
$sub->AddField("max(comments.addedDate) as maxDate");
$sub->AddField("comments.which");
$sub->AddTable("comments");
$sub->AddJoin("left","prods","prods.id = comments.which");
//$sub->AddOrder("comments.addedDate desc");
$sub->AddGroup("comments.which");
$sub->AddWhere(sprintf_esc("(prods.group1 = %d) or (prods.group2 = %d) or (prods.group3 = %d)",$this->id,$this->id,$this->id));
$s = new BM_Query("prods");
$s->AddField("cmts.addedDate as lastcomment");
$s->AddField("cmts.rating as lastcommentrating");
$s->AddJoin("left","(select comments.addedDate,comments.who,comments.which,comments.rating from (".$sub->GetQuery().") as dummy left join comments on dummy.maxDate = comments.addedDate and dummy.which = comments.which) as cmts","cmts.which=prods.id");
$s->attach(array("cmts"=>"who"),array("users as user"=>"id"));
$s->AddWhere(sprintf_esc("(prods.group1 = %d) or (prods.group2 = %d) or (prods.group3 = %d)",$this->id,$this->id,$this->id));
$r = !!$_GET["reverse"];
switch($_GET["order"])
{
case "type": $s->AddOrder("prods.type ".($r?"DESC":"ASC")); break;
case "party": $s->AddOrder("prods_party.name ".($r?"DESC":"ASC")); $s->AddOrder("prods.party_year ".($r?"DESC":"ASC")); $s->AddOrder("prods.party_place ".($r?"DESC":"ASC")); break;
case "release": $s->AddOrder("prods.releaseDate ".($r?"ASC":"DESC")); break;
case "thumbup": $s->AddOrder("prods.voteup ".($r?"ASC":"DESC")); break;
case "thumbpig": $s->AddOrder("prods.votepig ".($r?"ASC":"DESC")); break;
case "thumbdown": $s->AddOrder("prods.votedown ".($r?"ASC":"DESC")); break;
case "avg": $s->AddOrder("prods.voteavg ".($r?"ASC":"DESC")); break;
case "views": $s->AddOrder("prods.views ".($r?"ASC":"DESC")); break;
case "latestcomment": $s->AddOrder("lastcomment ".($r?"ASC":"DESC")); break;
default: $s->AddOrder("prods.name ".($r?"DESC":"ASC")); break;
}
$this->prods = $s->perform();
PouetCollectPlatforms($this->prods);
PouetCollectAwards($this->prods);
$s = new BM_Query("affiliatedboards");
$s->attach(array("affiliatedboards"=>"board"),array("boards as board"=>"id"));
$s->AddWhere(sprintf_esc("affiliatedboards.group=%d",$this->id));
$this->affil = $s->perform();
}
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:47,代码来源:groups.php
示例14: Load
function Load( $cached = false ) {
$s = new SQLSelect();
$s->AddTable("buttons");
$s->AddOrder("rand()");
$s->AddWhere("dead = 0");
$s->SetLimit("1");
$this->data = SQLLib::SelectRow($s->GetQuery());
$this->title = $this->data->type;
}
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:10,代码来源:box-index-affilbutton.php
示例15: migrateAuthors
/**
* For each author, add an AuthorHelper
*/
private function migrateAuthors()
{
/** @var SQLSelect $query */
$query = SQLSelect::create();
$query->setSelect('Author')->setFrom('News')->setDistinct(true);
$authors = $query->execute();
foreach ($authors as $author) {
/** Create a new author if it doesn't exist */
if (!($authorHelper = AuthorHelper::get()->filter(array('OriginalName' => trim($author['Author'])))->first())) {
/** @var AuthorHelper $authorHelper */
$authorHelper = AuthorHelper::create();
$authorHelper->OriginalName = $author['Author'];
$authorHelper->write();
}
$sql = "UPDATE `News` SET `AuthorHelperID` = '" . $authorHelper->ID . "' WHERE Author = '" . $author['Author'] . "'";
DB::query($sql);
}
}
开发者ID:firesphere,项目名称:silverstripe-newsmodule,代码行数:21,代码来源:NewsHolderPage.php
示例16: augmentSQL
/**
* Update any requests to limit the results to the current site
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
if (Subsite::$disable_subsite_filter) {
return;
}
if (Cookie::get('noSubsiteFilter') == 'true') {
return;
}
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
if (!$query->filtersOnID()) {
/*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
else */
$subsiteID = (int) Subsite::currentSubsiteID();
// Don't filter by Group_Subsites if we've already done that
$hasGroupSubsites = false;
foreach ($query->getFrom() as $item) {
if (is_array($item) && strpos($item['table'], 'Group_Subsites') !== false || !is_array($item) && strpos($item, 'Group_Subsites') !== false) {
$hasGroupSubsites = true;
break;
}
}
if (!$hasGroupSubsites) {
if ($subsiteID) {
$query->addLeftJoin("Group_Subsites", "\"Group_Subsites\".\"GroupID\" \n\t\t\t\t\t\t= \"Group\".\"ID\" AND \"Group_Subsites\".\"SubsiteID\" = {$subsiteID}");
$query->addWhere("(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR\n\t\t\t\t\t\t\"Group\".\"AccessAllSubsites\" = 1)");
} else {
$query->addWhere("\"Group\".\"AccessAllSubsites\" = 1");
}
}
// WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server)
$select = $query->getSelect();
if (isset($select[0]) && !$select[0] == 'COUNT(*)') {
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
}
}
}
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:39,代码来源:GroupSubsites.php
示例17: require_once
<?
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("id");
$sql->AddField("nickname as name");
$sql->AddField("avatar");
$sql->AddField("glops");
$sql->AddTable("users");
$r = array();
if ($_POST["search"])
{
$sql->AddWhere(sprintf_esc("nickname like '%%%s%%'",_like($_POST["search"])));
$sql->AddOrder(sprintf_esc("if(nickname='%s',1,2), nickname, lastLogin DESC",$_POST["search"]));
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
$sql->AddWhere(sprintf_esc("id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:28,代码来源:ajax_users.php
示例18: html
public function html()
{
global $db;
$html = "";
// Pull value from another table, if needed
if (isset($this->value_sqltable) && $this->value_sqltable != "") {
if (isset($this->value_sqlselectfield) && $this->value_sqlselectfield != "") {
$selectfield = $this->value_sqlselectfield;
} else {
$selectfield = $this->name;
}
$sel = new SQLSelect($this->value_sqltable);
$sel->selectfields[] = $selectfield;
if (!empty($this->value_sqlwherefields)) {
$sel->wherefields = $this->value_sqlwherefields;
}
$res = $sel->execute();
if (isset($res[strtoupper($selectfield)][0])) {
$this->value = $res[strtoupper($selectfield)][0];
}
}
// Unencode value
if (isset($this->value) && $this->value != "") {
$this->value = htmlspecialchars_decode($this->value);
}
if ($this->type == "header") {
if ($this->is_html_table) {
$html .= "<tr><td";
if ($this->colspan > 0) {
$html .= " colspan='" . $this->colspan . "'";
} else {
if ($this->maximum_fields_per_row) {
$html .= " colspan='" . $this->maximum_fields_per_row . "'";
}
}
$html .= ">";
}
$html .= "<h3>" . $this->label . "</h3>";
if ($this->helptext != "") {
$html .= "<span id='" . $this->id . "_helpblock' class='help-block " . $this->helptextclasses . "'>" . $this->helptext . "</span>";
}
if ($this->is_html_table) {
$html .= "</td></tr>";
}
return $html;
}
// Line separator, if applicable
if ($this->inline == true && $this->newline == true && $this->is_html_table == false) {
$html .= "<p>";
}
// New TR, for table form
if ($this->is_html_table && $this->type != "hidden") {
if ($this->newline) {
$html .= "<tr>";
}
$html .= "<td";
if ($this->colspan > 0) {
$html .= " colspan='" . $this->colspan . "'";
} else {
if ($this->maximum_fields_per_row) {
$html .= " colspan='" . $this->maximum_fields_per_row . "'";
}
}
$html .= ">";
}
// Open container div
if ($this->type != "hidden") {
$html .= "<div class='form-group";
if (isset($this->containerclasses)) {
$html .= " " . $this->containerclasses;
}
$html .= "'>";
}
// Label
$labelhtml = "";
if ($this->type != "hidden" && $this->type != "html" && $this->label != "") {
$labelhtml .= "<label";
if ($this->id != "") {
$labelhtml .= " for='" . $this->id . "'";
}
// Label classes
$labelhtml .= " class='form-control-label control-label";
if ($this->required == true) {
$labelhtml .= "requiredLabel";
}
if ($this->horizontal == true) {
$labelhtml .= " col-sm-2";
}
if (isset($this->labelclasses) && $this->labelclasses != "") {
$labelhtml .= " " . $this->labelclasses;
}
$labelhtml .= "'";
if (isset($this->labelattrs) && $this->labelattrs != "") {
$labelhtml .= " " . $this->labelattrs;
}
$labelhtml .= ">";
$labelhtml .= $this->label;
$labelhtml .= "</label>";
}
// Initialize input tag string
//.........这里部分代码省略.........
开发者ID:hughlaura,项目名称:php_oracle_handytools,代码行数:101,代码来源:FormElement.class.php
示例19: testLimitSetFromClauseString
/**
* Test passing in a LIMIT with OFFSET clause string.
*/
public function testLimitSetFromClauseString()
{
$query = new SQLSelect();
$query->setSelect('*');
$query->setFrom('"SQLQueryTest_DO"');
$query->setLimit('20 OFFSET 10');
$limit = $query->getLimit();
$this->assertEquals(20, $limit['limit']);
$this->assertEquals(10, $limit['start']);
}
开发者ID:DirektLvRepo,项目名称:silverstripe-framework,代码行数:13,代码来源:SQLQueryTest.php
示例20: require_once
<?
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("prods.id");
$sql->AddField("prods.name");
$sql->AddField("groups.name as groupName");
$sql->AddJoin("left","groups","groups.id = prods.group1");
$sql->AddTable("prods");
$r = array();
if ($_POST["search"])
{
$sql->AddWhere(sprintf_esc("prods.name like '%%%s%%'",_like($_POST["search"])));
$sql->AddOrder(sprintf_esc("if(prods.name='%s',1,2), prods.views desc, prods.name",$_POST["search"]));
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
$sql->AddWhere(sprintf_esc("prods.id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:28,代码来源:ajax_prods.php
注:本文中的SQLSelect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论