Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/PdoConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public function setAttribute($attribute, $value)
public function query($sql)
{
$params = func_get_args();

// Shift the SQL parameter off of the list
array_shift($params);

Expand All @@ -192,8 +193,18 @@ public function query($sql)
// Store this statement in our PDO object for easy use later
$this->statement = $this->prepare($sql, $this->fetchMode);

// Automatically detect parameters type
foreach ($params as $i => $param) {
$type = PDO::PARAM_STR;
if (is_int($param) || (is_string($param) && ctype_digit($param) && $param[0] !== '0')) {
$type = PDO::PARAM_INT;
}

$this->statement->bindValue($i + 1, $param, $type);
}

// Execute the query
$this->statement->execute($params);
$this->statement->execute();

// Return the statement
return $this->statement;
Expand Down