Connect To Database Using PDO In OOP PHP | Object Oriented PHP Tutorial | PHP Tutorial | mmtuts

37
6



How to Connect to A Database Using PDO PHP | OOP PHP Tutorial | Learn OOP PHP. In this OOP PHP tutorial you will learn how to connect to a database using PDO, which is the prefered method to use in Object Oriented Programming.

Article on PDO vs MySQLi:

➤ SPECIAL THANKS TO THE FOLLOWING PATRONS!

Name: Scooterman
Channel Link:
Description: I’m a guy.

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson:

Nguồn: xemhai.org

Xem thêm bài viết khác: https://xemhai.org/game/

37 COMMENTS

  1. Is it a good idea to write the credentials directly into the class constructor? Is it really safe?

    Please I really want to learn how to control a database correctly and absolutely safely. With an access data file or similar.

  2. Hi dude, your tutorials are amazing, probably the best on youtube & the easiest to follow, the php doc's say that all mysql functions are deprecated, in the dsn section Can I swap out msql for -> mysqli? My Print_r returned "Array ( [0] => mysql [1] => sqlite [2] => firebird [3] => dblib )"??

  3. Note:

    If you wish to use setAttribute, you must set the array attributes passed to the PDO constructor itself. If setting attributes with PDO::setAttribute() after instantiation of the object, the driver will not be using these attributes.

    So, it should be like this

    $pdo = new PDO($dsn, $this->username, $this->password, array(

    PDO::ATTR_ERRMODE, PDO::ERRMODE_EXEPTION
    ));

  4. You complicated this too much… Its actually very simple. Also, your connection doesnt use prepared statement, witch is fully unsecured way to drive your DataBase…

  5. on the page for artical doesnt have same code you used on video its same subject but searched for catch and its not on there i looked for the database file and thats not on ther either, can you upload to github the actual code you used?

  6. can you suggest me how can i connect to another database if one if failed to connect…Please help is anyone read this…

  7. hey brother we have our project submission on 2nd feb 2019 but we are facing postgres database connection problem in php using fedora can you please help us

  8. If you showed us how to create a database not manual way but with php before connecting. Currently i'm little stuck with that.

  9. I was telling people on the forum yesterday that you are one of the best Php tutor on YouTube. kudos. please can you do a video on making crud using Php pdo and oop? I can do it with Php procedural and also mysqli oop. thank you in advance

  10. after checking there is still error of empty properties. ———-Fatal error: Uncaught Error: Cannot access empty property—-

  11. Just did this, but the error message on the database that never existed didn't appear when I did this, even though the database didn't exist

  12. when i add the charset (.";charset=".$this->charset) in the dsn than it gives a error that says: Unknown character set. When i remove it it works. Why is that? chars are: uft8mb4

  13. Is the $password and $username attributes mentatory to pass int PDO (…).Can,t i connect the database without these?

  14. It's my first time to take php oop seriously and I find your series more helpful than my instructor.
    You earn a sub!

  15. Hey bro
    Your tutorials are awesome,outstanding and mind blowing. Loved it alot.Kindly make complete tutorials on php7 and pdo queries. and also laravel. Thanks alot in advance

LEAVE A REPLY

Please enter your comment!
Please enter your name here