Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Azure updates. #5293

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/sqlazure.php
Expand Up @@ -23,5 +23,5 @@ class JDatabaseDriverSqlazure extends JDatabaseDriverSqlsrv
* @var string
* @since 12.1
*/
public $name = 'sqlzure';
public $name = 'sqlazure';
}
6 changes: 4 additions & 2 deletions libraries/joomla/database/driver/sqlsrv.php
Expand Up @@ -136,6 +136,9 @@ public function connect()
{
$this->select($this->options['database']);
}

// Set charactersets.
$this->utf = $this->setUTF();
}

/**
Expand Down Expand Up @@ -806,7 +809,7 @@ public function select($database)
*/
public function setUTF()
{
// TODO: Remove this?
return false;
}

/**
Expand Down Expand Up @@ -1021,7 +1024,6 @@ protected function limit($query, $limit, $offset)
$rowNumberText = ', ROW_NUMBER() OVER (' . $orderBy . ') AS RowNumber FROM ';

$query = preg_replace('/\sFROM\s/i', $rowNumberText, $query, 1);
$query = 'SELECT * FROM (' . $query . ') _myResults WHERE RowNumber BETWEEN ' . $start . ' AND ' . $end;

return $query;
}
Expand Down
57 changes: 56 additions & 1 deletion libraries/joomla/database/query/sqlsrv.php
Expand Up @@ -136,6 +136,57 @@ public function __toString()

break;

case 'delete':
$query .= (string) $this->delete;
$query .= (string) $this->from;

if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}

if ($this->where)
{
$query .= (string) $this->where;
}

if ($this->order)
{
$query .= (string) $this->order;
}

break;

case 'update':
$query .= (string) $this->update;

if ($this->join)
{
// Special case for joins
foreach ($this->join as $join)
{
$query .= (string) $join;
}
}

$query .= (string) $this->set;

if ($this->where)
{
$query .= (string) $this->where;
}

if ($this->order)
{
$query .= (string) $this->order;
}

break;

default:
$query = parent::__toString();
break;
Expand Down Expand Up @@ -260,6 +311,11 @@ public function dateAdd($date, $interval, $datePart)
*/
public function processLimit($query, $limit, $offset = 0)
{
if ($limit == 0 && $offset == 0)
{
return $query;
}

$start = $offset + 1;
$end = $offset + $limit;

Expand All @@ -275,7 +331,6 @@ public function processLimit($query, $limit, $offset = 0)
$rowNumberText = ', ROW_NUMBER() OVER (' . $orderBy . ') AS RowNumber FROM ';

$query = preg_replace('/\sFROM\s/i', $rowNumberText, $query, 1);
$query = 'SELECT * FROM (' . $query . ') _myResults WHERE RowNumber BETWEEN ' . $start . ' AND ' . $end;

return $query;
}
Expand Down