Skip to content

Commit e956ed5

Browse files
committed
chore: refactor
1 parent 86557cb commit e956ed5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/QueryBuilder.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,9 @@ public function prepare($sql = null)
973973
$sql = $this->{'prepare' . $this->_method}();
974974
}
975975

976-
return empty($this->bindings) ? $sql : Connection::prepare($sql, $this->bindings);
976+
return empty($this->bindings)
977+
|| strpos($sql, '%s') === false
978+
? $sql : Connection::prepare($sql, $this->bindings);
977979
}
978980

979981
/**
@@ -1014,7 +1016,7 @@ protected function processConditions($conditions, $type = null)
10141016
$sql .= $this->prepareValueForWhere($clause, $this);
10151017
}
10161018

1017-
$sql = $this->removeLeadingbool($sql);
1019+
$sql = $this->removeLeadingBool($sql);
10181020
}
10191021

10201022
return $sql;
@@ -1079,7 +1081,7 @@ protected function prepareConditional($params, $bool = 'AND', $type = 'where')
10791081
*
10801082
* @return string
10811083
*/
1082-
protected function removeLeadingbool($sql)
1084+
protected function removeLeadingBool($sql)
10831085
{
10841086
return preg_replace('/and |or /i', '', $sql, 1);
10851087
}
@@ -1213,7 +1215,15 @@ protected function prepareOn($table, $column, $operator, $secondColumn, $bool =
12131215
*/
12141216
protected function getValueType($value)
12151217
{
1216-
return (\gettype($value) == 'integer') ? '%d' : ((\gettype($value) == 'double') ? '%f' : '%s');
1218+
$placeHolder = '%s';
1219+
1220+
if (\gettype($value) == 'integer') {
1221+
$placeHolder = '%d';
1222+
} elseif (\gettype($value) == 'double') {
1223+
$placeHolder = '%f';
1224+
}
1225+
1226+
return $placeHolder;
12171227
}
12181228

12191229
/**

0 commit comments

Comments
 (0)