php pdo check if update query successful
$req = $db->prepare('UPDATE `table` SET `content`= ? WHERE `id` = ?');
var $success = $req->execute($content,$id);
//execute() return true on success and false on fail
php pdo check if update query successful
$req = $db->prepare('UPDATE `table` SET `content`= ? WHERE `id` = ?');
var $success = $req->execute($content,$id);
//execute() return true on success and false on fail
php pdo check if record exists before insert
$sql = $dbh->prepare("SELECT COUNT(*) AS `total` FROM directory WHERE telephone = :phone");
$sql->execute(array(':phone' => $telephone));
$result = $sql->fetchObject();
if ($result->total > 0)
{
echo 'The telephone number: ' . $telephone. ' is already in the database<br />';
}
else
{
echo 'No rows matched the query.';
}
pdo insert or update if exists
REPLACE INTO ***** SET name = ?, slideView = ?, company = ?
pdo table exists
function emailExists($pdo, $email) { $stmt = $pdo->prepare("SELECT 1 FROM users WHERE email=?"); $stmt->execute([$email]); return $stmt->fetchColumn();)if (emailExists($pdo, $email)) { // found}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us