MySQL PDO Tutorial Lesson 8 – Insert, update and delete records




webinaction.co.uk How to insert, update and delete database records in a MySQL database to which we have connected using a PDO connection.

source


31 responses to “MySQL PDO Tutorial Lesson 8 – Insert, update and delete records”

  1. Do you still using this ugly text editor? It seems very powerful, but it's kind of hard to distinguish and see the content. It reminds me on Notepad++: powerful, but kind of retro and hard to distinguish. Hopefully, in the future videos — for which I'm really looking forward 😉 — you will use something nicer, like Sublime or Atom. They're really make it easier to follow. Anyway, those lessions were very, very helpfull! Thanks! 🙂

  2. Thanks this was brilliant, I watched a few others videos but what I liked about yours it that it is put very clearly, easy to understand and no extra stuff that is not needed. Thanks so much this helped me better understand this. Just brilliant.

  3. awesome lectures… learnt so many things….
    I have one difficulty hope you will give some help
    how to securely make connection to database. like in the video you have shown very basic syntax so how to make secure the username and password in the statement which is opening connection to database ????

  4. I got the example from your tutorial regarding update but when I have gone to use on my own project not quite the same results. I am updating a password field for someone who has lost their password. I have hashed the new password then used substr to get to 7 chars, I then stored in variable which I know raises eyebrows regarding security but then I have

    $stmt = $pdo->prepare("UPDATE users set password='$pass' where username='$user' LIMIT 1");

    Now my issue is I have all the data in an assoc array from the 1st prep statement which is validating whether account exists, in assoc array. Can the 2nd prepared statement still use that array? If it can't I need to rethink how I go about it.

    I have done a var_dump on $user, the original prep statement but keeping security in mind, I know using the variables is 1 problem but then a second comes in when I try to access the array within the prep statement?

    Thanks

  5. Richard, if in your delete example you had 2 or more people with the same names so you wanted to only delete the appropriate record how would you write the query. I have had a go but it does not delete the record.

    My code

    $stmt = $db->prepare("DELETE FROM names WHERE first = :first, last = :last, postcode = :postcode");
    $stmt->bindValue(':first', 'Indira');
    $stmt->bindValue(':last', 'Jones');
    $stmt->bindValue(':postcode', 'WV4 2TW');
    $stmt->execute();

    Thanks

Leave a Reply