From 18a542895762bb2fa3cdc64133e768fa150f2a24 Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Fri, 24 Dec 2021 07:18:17 -0800 Subject: [PATCH] Updating docs, fixes bug #163 --- docs/Statement/Delete.md | 4 +++- docs/Statement/Insert.md | 14 +++++++++----- docs/Statement/Update.md | 4 +++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/Statement/Delete.md b/docs/Statement/Delete.md index 1bd9f83..9e702ac 100644 --- a/docs/Statement/Delete.md +++ b/docs/Statement/Delete.md @@ -20,7 +20,9 @@ $database = new Database('mysql:host=localhost;dbname=test_db;charset=UTF8'); // DELETE FROM users $delete = new Delete($database, 'users'); -$affectedRows = $delete->execute()->rowCount(); +if (($result = $delete->execute()) !== false) { + $affectedRows = $result->rowCount(); +} ``` ## Methods diff --git a/docs/Statement/Insert.md b/docs/Statement/Insert.md index c9d14e9..42768fb 100644 --- a/docs/Statement/Insert.md +++ b/docs/Statement/Insert.md @@ -22,8 +22,9 @@ $insert = new Insert($database, ['id', 'username', 'password']); $insert->into('users') ->values(1234, 'user', 'passwd'); -$insertId = $insert->execute() - ->lastInsertId(); +if ($insert->execute()) { + $insertId = $database->lastInsertId(); +} ``` ## Methods @@ -82,9 +83,12 @@ use FaaPz\PDO\Statement\Insert; $database = new Database('mysql:host=localhost;dbname=test_db;charset=UTF8'); // INSERT INTO users (id, username, password) VALUES (? , ? , ?), (? , ? , ?) -$database->insert() - ->into('users') - ->columns(['id', 'username', 'password']) +$insert = new Insert($database, ['id', 'username', 'password']); +$insert->into('users') ->values([1, 'user1', 'passwd1']) ->values([2, 'user2', 'passwd2']); + +if (($result = $delete->execute()) !== false) { + $affectedRows = $result->rowCount(); +} ``` diff --git a/docs/Statement/Update.md b/docs/Statement/Update.md index 71521a1..3de747f 100644 --- a/docs/Statement/Update.md +++ b/docs/Statement/Update.md @@ -24,7 +24,9 @@ $update = new Update($database, [ 'password' ]); -$insertId = $insert->execute()->lastInsertId(); +if (($result = $insert->execute()) !== false) { + $affectedRows = $result->rowCount(); +} ``` ## Methods