Connect To A Database Using MySQLi and OOP PHP | Object Oriented PHP Tutorial | PHP Tutorial

25
6



Connect To A Database Using MySQLi and Object Oriented PHP | OOP PHP Tutorial | Learn OOP PHP. In this PHP tutorial you will learn how to connect to a database using object oriented PHP programming. We will also display data from the database on our website using a MVC pattern.

Article on PDO vs MySQLi:

➤ 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/

25 comments

  1. Sudhakar ColorWhistle 27 April, 2020 at 11:28 Reply

    I have problem that with the code in the video tutorial, my results do display but each line is displayed twice. So I have 4 results, while my database only has 2 in it.

  2. Dessu Fikir 27 April, 2020 at 11:28 Reply

    Please can you fix this error
    Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')'
    which raises on
    $conn = new mysqli($this->servername, this->username, $this->password, $this->dbname);

  3. Mr Smigz 27 April, 2020 at 11:28 Reply

    Can you check if the database did connected with this code ??
    if ($this->conn->connect_error) {

    die("Connection error" .$this->conn->connect_error);

    }

    echo "Connected Succesfully";

    return $this->conn; ???

  4. mindustrial 27 April, 2020 at 11:28 Reply

    I have problem that with the code in the video tutorial, my results do display but each line is displayed twice. So I have 4 results, while my database only has 2 in it.

  5. DAWEN 27 April, 2020 at 11:28 Reply

    Hello 👋 I'm used to using PDO on database handling, I just wanted to know what is better to use, mysqli or PDO? Thx.

  6. Kris Kelvin 27 April, 2020 at 11:28 Reply

    Thank you very much. Your videos are very, very helpful. Along with your great tutorials, I'm trying to fulfill my dream of becoming a programmer.

  7. cloudeweb 27 April, 2020 at 11:28 Reply

    Hello, great tutorial!
    I have a question: how can I access to single fields? something like this:

    foreach($datas as $data) {
    $username = $data["username "];
    $password= $data["password"];
    }

    I'd like echo only Username o Password here: $leads->showAllLeads();

    thanks!

  8. Flawless Proudmoore 27 April, 2020 at 11:28 Reply

    very nice and clean, although lack the controller part but its much easier to understand simplified code like this. Thank you, keep up the good work!

  9. Er1c Sebasta 27 April, 2020 at 11:28 Reply

    the server CPU and memory overhead of PDO is much more then MySQLi … and if you are not worried about migrating to a different database server down the road… MySQLi is much better. This is not what most people say… but it is a fact.

  10. Ree Jay Anigan 27 April, 2020 at 11:28 Reply

    hey mmtuts. I'm confused. Why did you create another class called ViewUser.inc.php if you can put the function that you've create to the class of user? is it because of MVC?

  11. Hamza Arshad 27 April, 2020 at 11:28 Reply

    My code didn't work when I included all the files "dbh.inc.php" "user.inc.php" and "viewuser.inc.php" in the same order as shown in the tutorial in my "index" file. However when I included "view" file in my "index" file and "user" file in "viewuser" file and "dbh" file in "user" file my code worked accurately. I also tried different arrangement of files in my "index" file but none of them worked. Solution required "How to include all the files in the Index file so that I can get the desired result." thanks

Leave a reply