-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from afgloeden/master
Changes related to PSR's
- Loading branch information
Showing
12 changed files
with
1,171 additions
and
874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/vendor/ | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,142 +1,150 @@ | ||
<?php namespace Uepg\LaravelSybase\Database\Query; | ||
<?php | ||
|
||
namespace Uepg\LaravelSybase\Database\Query; | ||
|
||
use Illuminate\Database\Query\Builder; | ||
use Illuminate\Database\Query\Grammars\Grammar; | ||
|
||
class SybaseGrammar extends Grammar { | ||
/** | ||
* All of the available clause operators. | ||
* | ||
* @var array | ||
*/ | ||
protected $operators = [ | ||
'=', '<', '>', '<=', '>=', '!<', '!>', '<>', '!=', | ||
'like', 'not like', 'between', 'ilike', | ||
'&', '&=', '|', '|=', '^', '^=', | ||
]; | ||
|
||
protected $builder; | ||
|
||
public function getBuilder(){ | ||
return $this->builder; | ||
} | ||
|
||
/** | ||
* Compile a select query into SQL. | ||
* | ||
* @param \Illuminate\Database\Query\Builder | ||
* @return string | ||
*/ | ||
public function compileSelect(Builder $query) | ||
{ | ||
$this->builder = $query; | ||
$components = $this->compileComponents($query); | ||
|
||
return $this->concatenate($components); | ||
} | ||
|
||
/** | ||
* Compile the "select *" portion of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param array $columns | ||
* @return string | ||
*/ | ||
protected function compileColumns(Builder $query, $columns) | ||
{ | ||
if (!is_null($query->aggregate)) { | ||
return; | ||
} | ||
|
||
$select = $query->distinct ? 'select distinct ' : 'select '; | ||
|
||
// If there is a limit on the query, but not an offset, we will add the | ||
// top clause to the query, which serves as a "limit" type clause | ||
// within the SQL Server system similar to the limit keywords available | ||
// in MySQL. | ||
if ($query->limit > 0 && $query->offset <= 0) { | ||
$select .= 'top ' . $query->limit . ' '; | ||
} | ||
|
||
return $select . $this->columnize($columns); | ||
} | ||
|
||
/** | ||
* Compile the "from" portion of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param string $table | ||
* @return string | ||
*/ | ||
protected function compileFrom(Builder $query, $table) | ||
{ | ||
$from = parent::compileFrom($query, $table); | ||
|
||
if (is_string($query->lock)) { | ||
return $from . ' ' . $query->lock; | ||
} | ||
|
||
if (!is_null($query->lock)) { | ||
return $from . ' with(rowlock,' . | ||
($query->lock ? 'updlock,' : '') . 'holdlock)'; | ||
} | ||
|
||
/** | ||
* All of the available clause operators. | ||
* | ||
* @var array | ||
*/ | ||
protected $operators = array( | ||
'=', '<', '>', '<=', '>=', '!<', '!>', '<>', '!=', | ||
'like', 'not like', 'between', 'ilike', | ||
'&', '&=', '|', '|=', '^', '^=', | ||
); | ||
|
||
protected $Builder; | ||
public function getBuilder(){ | ||
return $this->Builder; | ||
return $from; | ||
} | ||
|
||
/** | ||
* Compile the "limit" portions of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param int $limit | ||
* @return string | ||
*/ | ||
protected function compileLimit(Builder $query, $limit) | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Compile the "offset" portions of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param int $offset | ||
* @return string | ||
*/ | ||
protected function compileOffset(Builder $query, $offset) | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Compile a truncate table statement into SQL. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @return array | ||
*/ | ||
public function compileTruncate(Builder $query) | ||
{ | ||
return [ | ||
'truncate table ' . $this->wrapTable($query->from) => array() | ||
]; | ||
} | ||
|
||
/** | ||
* Get the format for database stored dates. | ||
* | ||
* @return string | ||
*/ | ||
public function getDateFormat() | ||
{ | ||
return 'Y-m-d H:i:s.000'; | ||
} | ||
|
||
/** | ||
* Wrap a single string in keyword identifiers. | ||
* | ||
* @param string $value | ||
* @return string | ||
*/ | ||
protected function wrapValue($value) | ||
{ | ||
if ($value === '*') { | ||
return $value; | ||
} | ||
|
||
|
||
/** | ||
* Compile a select query into SQL. | ||
* | ||
* @param \Illuminate\Database\Query\Builder | ||
* @return string | ||
*/ | ||
|
||
public function compileSelect(Builder $query) | ||
{ | ||
$this->Builder = $query; | ||
$components = $this->compileComponents($query); | ||
|
||
return $this->concatenate($components); | ||
} | ||
/** | ||
* Compile the "select *" portion of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param array $columns | ||
* @return string | ||
*/ | ||
protected function compileColumns(Builder $query, $columns) | ||
{ | ||
if ( ! is_null($query->aggregate)) return; | ||
|
||
$select = $query->distinct ? 'select distinct ' : 'select '; | ||
|
||
// If there is a limit on the query, but not an offset, we will add the top | ||
// clause to the query, which serves as a "limit" type clause within the | ||
// SQL Server system similar to the limit keywords available in MySQL. | ||
if ($query->limit > 0 && $query->offset <= 0) | ||
{ | ||
$select .= 'top '.$query->limit.' '; | ||
} | ||
|
||
return $select.$this->columnize($columns); | ||
} | ||
|
||
/** | ||
* Compile the "from" portion of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param string $table | ||
* @return string | ||
*/ | ||
protected function compileFrom(Builder $query, $table) | ||
{ | ||
$from = parent::compileFrom($query, $table); | ||
|
||
if (is_string($query->lock)) return $from.' '.$query->lock; | ||
|
||
if ( ! is_null($query->lock)) | ||
{ | ||
return $from.' with(rowlock,'.($query->lock ? 'updlock,' : '').'holdlock)'; | ||
} | ||
|
||
return $from; | ||
} | ||
|
||
/** | ||
* Compile the "limit" portions of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param int $limit | ||
* @return string | ||
*/ | ||
protected function compileLimit(Builder $query, $limit) | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Compile the "offset" portions of the query. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @param int $offset | ||
* @return string | ||
*/ | ||
protected function compileOffset(Builder $query, $offset) | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Compile a truncate table statement into SQL. | ||
* | ||
* @param \Illuminate\Database\Query\Builder $query | ||
* @return array | ||
*/ | ||
public function compileTruncate(Builder $query) | ||
{ | ||
return array('truncate table '.$this->wrapTable($query->from) => array()); | ||
} | ||
|
||
/** | ||
* Get the format for database stored dates. | ||
* | ||
* @return string | ||
*/ | ||
public function getDateFormat() | ||
{ | ||
return 'Y-m-d H:i:s.000'; | ||
} | ||
|
||
/** | ||
* Wrap a single string in keyword identifiers. | ||
* | ||
* @param string $value | ||
* @return string | ||
*/ | ||
protected function wrapValue($value) | ||
{ | ||
if ($value === '*') return $value; | ||
|
||
return '['.str_replace(']', ']]', $value).']'; | ||
} | ||
|
||
return '[' . str_replace(']', ']]', $value) . ']'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<?php | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
namespace Uepg\LaravelSybase\Database\Query; | ||
|
||
use Illuminate\Database\Query\Processors\Processor; | ||
|
||
class SybaseConnector extends Processor | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.