Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Execute returns false, no exception thrown
- $so = $rh->pdo->prepare("SELECT * FROM config");
- if($so->execute(['Test']) === FALSE) echo '1. False returned <br />';
- // Execute does not return false, no exception thrown
- $so = $rh->pdo->prepare("SELECT * FROM config");
- if($so->bindValue(1, 'Test') === FALSE) echo '2. Binding failed <br />';
- if($so->execute() === FALSE) echo '2. False not returned <br />';
- // Execute returns false, no exception thrown
- $so = $rh->pdo->prepare("SELECT * FROM config WHERE webmaster_name = ?");
- if($so->execute(['Test', 'Wee']) === FALSE) echo '3. False returned <br />';
- // Execute does not return false, no exception thrown
- $so = $rh->pdo->prepare("SELECT * FROM config WHERE webmaster_name = ?");
- $so->bindValue(1, 'Test');
- if($so->bindValue(2, 'Wee') === FALSE) echo '4. Binding failed <br />';
- if($so->execute() === FALSE) echo '4. False not returned <br />';
- Outputs:
- 1. False returned
- 2. Binding failed
- 3. False returned
- 4. Binding failed
- $user_info = $rh->pdo->query("SELECT * FROM users WHERE user_id = 1")->fetch();
- // vs
- $so = $rh->pdo->query("SELECT * FROM users WHERE user_id = 1");
- if($so === FALSE) // Throw an exception
- $user_info = $so->fetch();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement