bUTschy.de

  • code

PDO::PARAM_

Hier nur kurz eine PDO Funktionsweise mit bindParam

#prepare #bindParam #execute #PDO::PARAM

SELECT

$sql = 'SELECT `uid` FROM * WHERE `uid` = :uid';
$stmt = $db->prepare($sql);
$stmt->bindParam(':uid', $_POST['uid'], PDO::PARAM_INT);
$stmt->execute();

INSERT

$sql = 'INSERT INTO * (uname) VALUES (:uname)';
$stmt = $db->prepare($sql);
$stmt->bindParam(':uname', $_POST['uname'], PDO::PARAM_STR);      
$stmt->execute();

UPDATE

$sql = 'UPDATE * SET `uname` = :uname WHERE `uid` = :uid';
$stmt = $db->prepare($sql);                                 
$stmt->bindParam(':uname', $_POST['uname'], PDO::PARAM_STR);      
$stmt->bindParam(':uid', $_POST['uid'], PDO::PARAM_INT);  
$stmt->execute();

DELETE

$sql = 'DELETE FROM * WHERE `uid` = :uid';
$stmt = $db->prepare($sql);
$stmt->bindParam(':uid', $_POST['uid'], PDO::PARAM_INT);  
$stmt->execute();
  • 0 Kommentare
  • 6596 Klicks

▼ Kommentare


Kommentar hinzufügen