Answers for "php pdo update if exist"

PHP
1

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
Posted by: Guest on October-28-2020
0

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.';
}
Posted by: Guest on October-01-2021
0

pdo insert or update if exists

REPLACE INTO ***** SET name = ?, slideView = ?, company = ?
Posted by: Guest on August-04-2020
0

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}
Posted by: Guest on September-13-2021

Browse Popular Code Answers by Language