Skip to content

Commit 7c2edfc

Browse files
aedarttaylorotwell
andauthored
[9.x] Add resource binding (#41233)
* Add support for binding resources (#41180) * Remove duplicate code (#41180) Binding of resource values is now handled in `Connection`. * formatting Co-authored-by: Taylor Otwell <[email protected]>
1 parent 3f2162a commit 7c2edfc

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

src/Illuminate/Database/Connection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,11 @@ public function bindValues($statement, $bindings)
616616
$statement->bindValue(
617617
is_string($key) ? $key : $key + 1,
618618
$value,
619-
is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR
619+
match (true) {
620+
is_int($value) => PDO::PARAM_INT,
621+
is_resource($value) => PDO::PARAM_LOB,
622+
default => PDO::PARAM_STR
623+
},
620624
);
621625
}
622626
}

src/Illuminate/Database/PostgresConnection.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,9 @@
99
use Illuminate\Database\Schema\PostgresBuilder;
1010
use Illuminate\Database\Schema\PostgresSchemaState;
1111
use Illuminate\Filesystem\Filesystem;
12-
use PDO;
1312

1413
class PostgresConnection extends Connection
1514
{
16-
/**
17-
* Bind values to their parameters in the given statement.
18-
*
19-
* @param \PDOStatement $statement
20-
* @param array $bindings
21-
* @return void
22-
*/
23-
public function bindValues($statement, $bindings)
24-
{
25-
foreach ($bindings as $key => $value) {
26-
if (is_int($value)) {
27-
$pdoParam = PDO::PARAM_INT;
28-
} elseif (is_resource($value)) {
29-
$pdoParam = PDO::PARAM_LOB;
30-
} else {
31-
$pdoParam = PDO::PARAM_STR;
32-
}
33-
34-
$statement->bindValue(
35-
is_string($key) ? $key : $key + 1,
36-
$value,
37-
$pdoParam
38-
);
39-
}
40-
}
41-
4215
/**
4316
* Get the default query grammar instance.
4417
*

0 commit comments

Comments
 (0)