bUTschy.de

  • Code

CRUD prepare bindParam execute PDO::PARAM

Hier nur kurz eine CRUD? oder SIUD... mit PDO!

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
  • 6231 Klicks

Kommentare

Kommentar hinzufügen

🙂 😃 😀 😝 😇 😉 😋 😎 🤔 🙄 🙁 😕 😴 😧 😠 😢 😡