Skip to content

Commit

Permalink
Minor update:
Browse files Browse the repository at this point in the history
Fix the crash under PHP 8.x version
  • Loading branch information
rawsrc committed Mar 21, 2021
1 parent 23f39e4 commit 55ffb5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions PDOPlusPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,12 @@ private function builtPrepareAndAttachValuesOrParams(string $sql, array $prepare
{
// replace tags by the out param value
foreach ($this->tagsByMode([self::VAR_OUT]) as $tag => $v) {
$sql = str_replace($tag, $v['value'], $sql);
$sql = str_replace($tag, (string)$v['value'], $sql);
}

// replace tags by plain sql values
foreach ($this->tagsByMode([self::VAR_IN_SQL, self::VAR_INOUT_SQL]) as $tag => $v) {
$sql = str_replace($tag, self::sqlValue($v['value'], $v['type'], false, $this->current_cnx_id), $sql);
$sql = str_replace($tag, (string)self::sqlValue($v['value'], $v['type'], false, $this->current_cnx_id), $sql);
}

// stop if there's no need to create a statement
Expand Down Expand Up @@ -1079,7 +1079,7 @@ private function builtPrepareAndAttachValuesOrParams(string $sql, array $prepare
$this->params_already_bound = true;
}

// explicit casting fot values by ref and rebinding for null values
// explicit cast for values by ref and rebinding for null values
$data_by_ref = $this->tagsByMode([self::VAR_IN_BY_REF, self::VAR_INOUT_BY_REF]);
foreach ($data_by_ref as $tag => &$v) {
$current = self::sqlValue($v['value'], $v['type'], true);
Expand All @@ -1096,7 +1096,7 @@ private function builtPrepareAndAttachValuesOrParams(string $sql, array $prepare
$this->last_bound_type_tags_by_ref[$tag] = $pdo_type($v['type']);
}

// explicit casting for var by ref
// explicit cast for var by ref
if ($v['value'] !== null) {
$v['value'] = $current[0];
}
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## **A PHP full object PDO Wrapper in one class**

`PDOPlusPlus` (alias `PPP`) is **a one single class PDO Wrapper for PHP** with a
`PDOPlusPlus` (alias `PPP`) is **a single class PDO Wrapper for PHP** with a
revolutionary fluid SQL syntax.
You do not have anymore to use PDO in classical way, you can completely omit the notions of
`prepare()`, `bindValue()`, `bindParam()`. The usage of these mechanisms is now hidden by `PDOPlusPlus`.
Expand Down Expand Up @@ -261,10 +261,8 @@ INSERT INTO t_video (video_title, video_support, video_multilingual, video_chapt
VALUES (:XMEDem6153, :oASqvP7440, :mbfaTY4236, :FJzRWx7446, :FVHvqL4843, :tcCvZo8956, :JRtazM4176);
```
Let's truncate the table and then add the whole list of films at once.<br>
This time, I will use a `PDOStatement` based on references (`->bindParam()`) as there are many iterations to do.

Please note, to pass the references to the `PDOPlusPlus` instance, you **MUST** use a specific reference injector
returned by `->injectorInByRef();`. Otherwise it will not work.
This time, I will use a `PDOStatement` based on references (`->bindParam()`) as there are many iterations to do.
I will use the injector returned by `->injectorInByRef();`.
```php
include 'PDOPlusPlus.php';
$ppp = new PPP();
Expand Down

0 comments on commit 55ffb5d

Please # to comment.