You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Database/SybaseConnection.php
+60-33Lines changed: 60 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,13 @@ private function compileForSelect(Builder $builder, $bindings) {
102
102
$tables = $alias['table'];
103
103
}
104
104
105
-
$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."'");
105
+
$explicitDB = explode('..', $tables);
106
+
if(isset($explicitDB[1])){
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{
109
+
$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."'");
@@ -200,7 +209,12 @@ private function compileBindings($query, $bindings)
200
209
$table = $campos;
201
210
}
202
211
if(!array_key_exists($table, $new_format)){
203
-
$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."'");
212
+
$explicitDB = explode('..', $table);
213
+
if(isset($explicitDB[1])){
214
+
$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]."'");
215
+
}else{
216
+
$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."'");
$indentity = $this->getPdo()->query("select name as 'column' from syscolumns where status & 128 = 128 AND object_name(id)='".$from."'")->fetchAll($me->getFetchMode())[0];
286
-
287
-
if(count($indentity) == 0){
288
-
$primaries = $this->getPdo()->query("SELECT index_col(object_name(i.id), i.indid, c.colid) AS primary_key FROM sysindexes i, syscolumns c WHERE i.id = c.id AND c.colid <= i.keycnt AND i.id = object_id('".$from."')")->fetchAll($me->getFetchMode());
281
+
$explicitDB = explode('..', $from);
282
+
if(isset($explicitDB[1])){
283
+
$identity = $this->getPdo()->query("select b.name as 'column' from ".$explicitDB[0]."..syscolumns AS b INNER JOIN ".$explicitDB[0]."..sysobjects AS a ON a.id = b.id WHERE status & 128 = 128 AND a.name ='".$explicitDB[1]."'")->fetchAll($me->getFetchMode())[0];
284
+
}else{
285
+
$identity = $this->getPdo()->query("select name as 'column' from syscolumns where status & 128 = 128 AND object_name(id)='".$from."'")->fetchAll($me->getFetchMode())[0];
286
+
}
287
+
if(count($identity) == 0){
288
+
if(isset($explicitDB[1])){
289
+
$primaries = $this->getPdo()->query("SELECT index_col(".$from.", i.indid, c.colid) AS primary_key FROM ".$explicitDB[0]."..sysindexes i, ".$explicitDB[0]."..syscolumns c WHERE i.id = c.id AND c.colid <= i.keycnt AND i.id = object_id('".$from."')")->fetchAll($me->getFetchMode());
290
+
}else{
291
+
$primaries = $this->getPdo()->query("SELECT index_col(".$from.", i.indid, c.colid) AS primary_key FROM sysindexes i, syscolumns c WHERE i.id = c.id AND c.colid <= i.keycnt AND i.id = object_id('".$from."')")->fetchAll($me->getFetchMode());
292
+
}
289
293
foreach($primariesas$primary)
290
294
{
291
295
$new_arr[] = $primary->primary_key.'+0 AS '.$primary->primary_key;
@@ -294,8 +298,8 @@ public function select($query, $bindings = array(), $useReadPdo = true)
294
298
$res_primaries = implode(', ',$new_arr);
295
299
$where_primaries = implode(' AND ',$where_arr);
296
300
}else{
297
-
$res_primaries = $indentity->column.'+0 AS '.$indentity->column;
@@ -304,10 +308,33 @@ public function select($query, $bindings = array(), $useReadPdo = true)
304
308
return$this->getPdo()->query("SELECT #tmpPaginate.*, #tmpTable.idTmp FROM #tmpTable INNER JOIN #tmpPaginate ON ".$where_primaries." WHERE #tmpTable.idTmp "
305
309
. "BETWEEN ".($offset+1) ." AND ". ($offset+$limit)
306
310
." ORDER BY #tmpTable.idTmp ASC")->fetchAll($me->getFetchMode());
0 commit comments