Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php pdo Check if row exists in the database

$stmt = $conn->prepare('SELECT * FROM table WHERE ID=?');
$stmt->bindParam(1, $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);

if( ! $row)
{
    echo 'nothing found';
}

/*
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // Same here
if( ! $rows)
{
    echo 'nothing found';
}
*/
Comment

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.';
}
Comment

pdo insert or update if exists

REPLACE INTO ***** SET name = ?, slideView = ?, company = ?
Comment

php pdo check if record exists before insert

ALTER TABLE `requests` ADD UNIQUE `imdbid_unique`(`imdbid`);
Comment

PREVIOUS NEXT
Code Example
Php :: hou to fill value in input box using php 
Php :: magento2 migration 
Php :: Obtener rol de usuario registrado en WordPress 
Php :: php send response without quitting 
Php :: Including ACF in a custom theme or plugin 
Php :: can i do a relation between 2 coulnm in mongodb laravel 
Php :: laravel 8 api validation 
Php :: laravel pagination bootstrap sorting column 
Php :: auto complete order paid 
Php :: php join array to parenthesis 
Php :: laravel migration unknown column type double requested 
Php :: bitnami lightsail PHP Fatal error: Out of memory (allocated 
Php :: return multiple rows from mysqli php and encode JSON 
Php :: convert php to curl 
Php :: php wxplode 
Php :: check if order id exists wordpress woccommerce 
Php :: php decrement variable by 1 
Php :: pakistan standard time zone 
Php :: laravel , How can I increment and decrement value with unique id 
Php :: laravel routes options 
Php :: cmd download file from url 
Php :: how to rrestart brew php 
Php :: Laravel API ResourceCollection doesnt works 
Php :: upload image to backend (see rest of the link) 
Php :: fuzzy search in php with percentage 
Php :: htmlentities (PHP 4, PHP 5, PHP 7, PHP 8) htmlentities — Convert all applicable characters to HTML entities 
Php :: cakephp 3 get app url 
Php :: laravel eloquent where if a variable has value 
Php :: plesk change php version 
Php :: laravel view not created using foreign keys 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =