Skip to content

Commit 61f00cd

Browse files
author
Gabriel Tadra Mainginski
committed
Revert "Probably fixed #4 and #5"
This reverts commit 1a46623.
1 parent 458672d commit 61f00cd

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

Database/SybaseConnection.php

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,46 +99,33 @@ private function compileForSelect(Builder $builder, $bindings) {
9999
if(count($bindings)==0){
100100
return [];
101101
}
102+
102103
$bindings = $this->prepareBindings($bindings);
104+
103105

104106
$arrTables = [];
105107
array_push($arrTables, $builder->from);
106-
107108
if(!empty($builder->joins)){
108109
foreach($builder->joins as $join){
109-
110110
array_push($arrTables, $join->table);
111111
}
112112
}
113113
$new_format = [];
114114
foreach($arrTables as $tables){
115-
preg_match("/(?:(?'table'.*)(?: as )(?'alias'.*))|(?'tables'.*)/", $tables, $alias);
116-
if(empty($alias['alias'])){
117-
$tables = $alias['tables'];
118-
}else{
119-
$tables = $alias['table'];
120-
}
121-
115+
122116
$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."'");
123-
$types[$tables] = $queryRes->fetchAll(\PDO::FETCH_NAMED);
124-
117+
$types[$tables] = $queryRes->fetchAll(\PDO::FETCH_NAMED);
118+
125119
foreach ($types[$tables] as &$row) {
126-
$tipos[$row['name']] = $row['type'];
127-
$tipos[$tables.'.'.$row['name']] = $row['type'];
128-
if(!empty($alias['alias'])){
129-
$tipos[$alias['alias'].'.'.$row['name']] = $row['type'];
130-
}
120+
$tipos[$row['name']] = $row['type'];
121+
$tipos[$tables.'.'.$row['name']] = $row['type'];
131122
}
132123

133124
$new_format[$tables] = [];
125+
134126
}
135127
$wheres = (array)$builder->wheres;
136128
for($ind = 0; $ind < count($wheres); $ind++ ){
137-
if(!isset($wheres[$ind]['value'])){
138-
$ind++;
139-
unset($wheres[$ind]);
140-
break;
141-
}
142129

143130
if(in_array(strtolower($tipos[$wheres[$ind]['column']]), $this->without_quotes)){
144131
$new_binds[$ind] = $bindings[$ind]/1;
@@ -180,10 +167,14 @@ private function compileBindings($query, $bindings)
180167
case "delete":
181168
preg_match("/(?'tables'.*) where (?'attributes'.*)/i" ,$query, $matches);
182169
break;
170+
default:
171+
return [];
183172
}
184173

185174
$desQuery = array_intersect_key($matches, array_flip(array_filter(array_keys($matches), 'is_string')));
186175

176+
177+
187178
if(is_array($desQuery['tables'])){
188179
$desQuery['tables'] = implode($desQuery['tables'], ' ');
189180
}

0 commit comments

Comments
 (0)