Skip to content

Commit fa0df59

Browse files
author
Gabriel Tadra Mainginski
committed
Fix #9 - All operations working with multiple databases, less if you use pagination in a table without a identity (only primary key).
1 parent 369cd35 commit fa0df59

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Database/SybaseConnection.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ private function compileForSelect(Builder $builder, $bindings) {
104104

105105
$explicitDB = explode('..', $tables);
106106
if(isset($explicitDB[1])){
107-
$queryRes = $this->getPdo()->query("select b.name, c.name AS type from ".$explicitDB[0]."..sysobjects a noholdlock JOIN ".$explicitDB[0]."..syscolumns b noholdlock ON a.id = b.id JOIN ".$explicitDB[0]."..systypes c noholdlock ON b.usertype = c.usertype and a.name = '".$explicitDB[1]."'");
108-
}else{
107+
$queryRes = $this->getPdo()->query("select a.name, b.name AS type FROM ".$explicitDB[0]."..syscolumns a noholdlock JOIN ".$explicitDB[0]."..systypes b noholdlock ON a.usertype = b.usertype and object_name(a.id, db_id('".$explicitDB[0]."')) = '".$explicitDB[1]."'");
108+
}else{
109109
$queryRes = $this->getPdo()->query("select a.name, b.name AS type FROM syscolumns a noholdlock JOIN systypes b noholdlock ON a.usertype = b.usertype and object_name(a.id) = '".$tables."'");
110110
}
111111

@@ -185,7 +185,7 @@ private function compileBindings($query, $bindings)
185185
unset($matches);
186186
unset($query_type);
187187
preg_match_all("/\[([^\]]*)\]/", $desQuery['attributes'], $arrQuery);
188-
preg_match_all("/\[([^\]]*)\]/", $desQuery['tables'], $arrTables);
188+
preg_match_all("/\[([^\]]*)\]/", str_replace( "].[].[", '..' , $desQuery['tables']), $arrTables);
189189

190190
$arrQuery = $arrQuery[1];
191191
$arrTables = $arrTables[1];
@@ -206,7 +206,12 @@ private function compileBindings($query, $bindings)
206206
$table = $campos;
207207
}
208208
if(!array_key_exists($table, $new_format)){
209-
$queryRes = $this->getPdo()->query("select a.name, b.name AS type FROM syscolumns a noholdlock JOIN systypes b noholdlock ON a.usertype = b.usertype and object_name(a.id) = '".$table."'");
209+
$explicitDB = explode('..', $table);
210+
if(isset($explicitDB[1])){
211+
$queryRes = $this->getPdo()->query("select a.name, b.name AS type FROM ".$explicitDB[0]."..syscolumns a noholdlock JOIN ".$explicitDB[0]."..systypes b noholdlock ON a.usertype = b.usertype and object_name(a.id, db_id('".$explicitDB[0]."')) = '".$explicitDB[1]."'");
212+
}else{
213+
$queryRes = $this->getPdo()->query("select a.name, b.name AS type FROM syscolumns a noholdlock JOIN systypes b noholdlock ON a.usertype = b.usertype and object_name(a.id) = '".$table."'");
214+
}
210215
$types[$table] = $queryRes->fetchAll(\PDO::FETCH_ASSOC);
211216
for($k = 0; $k < count($types[$table]); $k++){
212217
$types[$table][$types[$table][$k]['name']] = $types[$table][$k];
@@ -215,7 +220,7 @@ private function compileBindings($query, $bindings)
215220
$new_format[$table] = [];
216221
}
217222
}
218-
223+
echo $table;
219224
if(!$itsTable){
220225
if(count($bindings)>$ind){
221226
array_push($new_format[$table], ['campo' => $campos, 'binding' => $ind]);

0 commit comments

Comments
 (0)