Much the same as Nitin Gupta below, I followed your entire Procedural PHP course and was very impressed. What would it take to get you to complete this OOP MVC PHP course? I don't have much to give, but if a 1000 people following these videos donated $10... well, that's $10,000. Just saying.
hey i am waiting for you to add more videos about oops php. i followed your whole series about php. now i want to learn oops php. if not your videos then please suggest me a good channel or book or some links?
I have to say, your videos helped me tremendously. Please do a video on how you can fetch stored data according to user ID using OOP. greatly appreciate it
I really like your PHP tutorials. I've watched several of your videos. The only complaint I have is that you use mysqli and not PDO method for database connections. I use PDO because of its versatility and wish you could use it as well to help me and others follow your tutorials more easily. Thanks anyway for the help you've been to me! Great job...
These are great tutorials! Thank you so much for providing these. Regarding timeframe 11:07 ... Not sure, but I think PHP 7.1 may require initializing $data somewhere after line 5 with something like "data = array();" _So function would look like:_ protected function getAllUsers() { *$data = array();* $sql = "SELECT * FROM user"; $result = $this->connect()->query($sql); $numRows = $result->num_rows; if ($numRows > 0) { while($row = $result->fetch_assoc()) { $data[] = $row; } return $data; } } At least that's the only way I could get it to work on Ubuntu 18.04 with PHP 7.2.15. I was getting this error: "PHP Fatal error: Uncaught Error: [] operator not supported for strings in ... includes/user.inc.php:14 ... I hope this helps someone!
Best lessons on the web! You got a gift to explain complex things easily. I watched and finished your PHP series and it has helped me a lot. Keep it up bro, you rock.
Good. Tutorial..i have a doubt inline number 14:58 .. we have included database connection. Doest it really required. As the third file extends from the dbh would be possible to fetch db connection.?
Great video! However one thing is not clear to me: why not assign the values to the private variables straight away and not in the "connect" function? Thanks!
Sir I am creating a register and login system using php object oriented approach however I've already created it in procedural style. What I am confusing at is is it necessary to use $conn = new mysqli() inside a connect() function ? can't we use it write is outside that connect function by creating constants instead of variables and then extend the Dbh class and use the $conn directly with prepared statement ?
In which folder is the database stored? Is it in the same folder where you store your php files, or do you create a subfolder like when you do to put CSS, JS or images for example, or is it somewhere else?
I’m not sure I understand the question. In the video I show that I save the dbh file inside a ‘includes’ folder. If you mean the database we create inside phpmyadmin, then it gets stored somewhere inside our XAMPP installation, and is not something you need to worry about. 🙂
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.
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?
Nice video! Are you going to continue with this series? Maybe you can make a long video where we can see the advantage of OOP PHP well. You have given the example of a login system in the last episodes. We know how to make a login system from the normal PHP tutorial series. But maybe you can make a video about it in OOP PHP. And point out the way you need to do it in OOP PHP and the advantage more than the login system itself.
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
Good day sir Nice tutorial . . Can i put my connection to database in __construct method or not ?? just wondering so it will be automatically connected :D ??
How do i output only one column? not in the function code but in HTML. Fore example: I want one html field to output name, second to output id. i get all the rows in one field if i use the above method.
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";
Was wondering why use the properties in the dbh class if there is nothing set in this example. Can use enter the properties directly when creating the $conn object. But I'm guessing you want to explain it in an OOP fashion where later some values can be put in the connect function.
It's a good habit to keep sensitive info private. If I were to include the database info directly in the $conn, then the info would be protected and not private. Since we only want to make it possible to access this info in the Dbh class.
Hi, Your lessons are really helpful. Thank you for your work! Maybe anybody can clarify a little thing to me. I have done everything the same as in video, but when I try to check result - each element from DB returns 2 times. Where can be a mistake? Thank you in advance.
very good tutorial mate. though one thing isn't very clear to me. Why create a new class ViewUser which extends the User class, and why not using the same User class for both methods getAllUsers() and showAllUsers()? thanks!
We are separating the two classes because we want to have one class which handles all database queries, and another class that shows the data on the website. It is perfectly possible to do it the way you are suggesting, but because we are following the OOP MVC design pattern, we are separating the functionalities.
I apologize for being such a newbie but I understand that this connection file is kept in a includes folder. Now i have a file called login.php and register.php which need that connection information. I put at the top of these files the include reference to this connection information file. However when i now try to use this connection information in both of these files i get a undefined variable for $conn. What am I missing?
That seems odd since the $conn should be accesible inside the login and register files. Try checking that you spell everything correctly and included the file path in the correct way.
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.
@@Dani_Krossing Oh yes, you are right l overlooked that one class extends the other. So I think in javascript the order doesn't matter but in PHP it does. However I'm not sure about javascript too. The simplest way is to try it out. Perhaps you know how Javascript reacts if one do not care about the order of included javascript classes.
Can someone give me some tips on how to insert data using this method? I've been toying around with it for some time, but I haven't had any luck so far
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);
Great tutorial series, learnt loads so far. I'm getting an error message at the end of this one. Not sure where I've gone wrong. Gone through it several times. Any thoughts anyone? "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\OOP_12\includes\viewuser.inc.php on line 7"
Please use naming conventions. don't use getAllUsers, use getUsers, that way you can add an optional "limit" parameter so you don't overwhelm your database retriving 9 million users at once, name your users variable "users" because it contains User instances (not really because you didn't use class mapping, but it should), that way you know what the variable contains. If you name it "datas", fuck knows what's in that variable, plus you could have another variable with the same generic ass name later in your code.
That is also a possible way to query :) However it is using PDO and not MySQLi like mentioned in the video title. In a later episode I go over PDO connections as well since PDO and MySQLi both have pros and cons ;)
Man, your lessons are exciting! I'm from Ukraine, but l understand your videos better, than videos in native tongue from other authors!
Геннадий Акулов Thank you :)
I am from Russia and can agree with Gennadi.
I'm from Brazil, and I can agree with you guys :D
Agree with you all and I'm from Moldova)
I'm from Poland. I won't argue with any of you, guys :-)
Thank you for the excellent tutorial.
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!
The first video that I've watched that actually helped me understand oop ;) thank you so much
Thanks Dani, you helped me finally connect to my database via PHP and retreive some data. :) Here's a like. It's the least I can do.
Much the same as Nitin Gupta below, I followed your entire Procedural PHP course and was very impressed. What would it take to get you to complete this OOP MVC PHP course? I don't have much to give, but if a 1000 people following these videos donated $10... well, that's $10,000. Just saying.
Thanks for this info bro, now I can connect and fetch my data from my database using OOP, because all I know is procedural programming.
Such a great teacher! I hope to watch more videos from you! I watched all videos at once!
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.
hey i am waiting for you to add more videos about oops php. i followed your whole series about php. now i want to learn oops php. if not your videos then please suggest me a good channel or book or some links?
I have to say, your videos helped me tremendously. Please do a video on how you can fetch stored data according to user ID using OOP. greatly appreciate it
Hello, man. I'm from Brazil and I love your videos. You're so good. Congrats, teacher.
I am enjoying your tutorial series a lot. You explain so well.
I really like your PHP tutorials. I've watched several of your videos. The only complaint I have is that you use mysqli and not PDO method for database connections. I use PDO because of its versatility and wish you could use it as well to help me and others follow your tutorials more easily. Thanks anyway for the help you've been to me! Great job...
Really useful now i find programming interesting thanks :)
These are great tutorials! Thank you so much for providing these.
Regarding timeframe 11:07 ... Not sure, but I think PHP 7.1 may require initializing $data somewhere after line 5 with something like "data = array();"
_So function would look like:_
protected function getAllUsers() {
*$data = array();*
$sql = "SELECT * FROM user";
$result = $this->connect()->query($sql);
$numRows = $result->num_rows;
if ($numRows > 0) {
while($row = $result->fetch_assoc()) {
$data[] = $row;
}
return $data;
}
}
At least that's the only way I could get it to work on Ubuntu 18.04 with PHP 7.2.15.
I was getting this error: "PHP Fatal error: Uncaught Error: [] operator not supported for strings in ... includes/user.inc.php:14 ...
I hope this helps someone!
Yeah it help me to fix the errors, thanks!
thanks that's so helpful
Thank you so much for this tutorial. Hoping for the continuation of this series.
You are an amazing teacher... love the way you make it so simple to understand
Thanks very much! This was exactly what i was looking for. Great tutorial.
thanks for your lessons its so easy to follow specially your
html css tutorials
The sound of your voice always makes me very happy. I love your videos!
Very precise and clearly explained. I subbed you.
Best lessons on the web! You got a gift to explain complex things easily. I watched and finished your PHP series and it has helped me a lot. Keep it up bro, you rock.
Thank you :) I'm glad you found the lessons useful
Amazing video 💯👍🙏
This video helped me a lot. Thank you man!..... I'll share you until the end of times!
One of the best tutorials i ever seen , thank you very much for this interesting video !
concise and understandable!
please make a blog or some news website example using oop and mvc whit routing etc. your way of explanation is very clear. thank you!
Good. Tutorial..i have a doubt inline number 14:58 .. we have included database connection. Doest it really required. As the third file extends from the dbh would be possible to fetch db connection.?
your tutorials are amazing, please keep working on them as possible as you can :D
Very nice explanation....Thanks man
dude you are sent from heaven, for sure. thanks for your amazing work.
thanks for ur knowledge
You are amazing!
This has just answered a big question! Thank you very much Daniel :-)
Is it possible to use OOP to make a login system?
so so so so good!!!!
it's really helpfull to me. could u make complete tutorial on oophp with mysqli(E-commers level)
Hey man amazing tutorials on php on youtube by far. Keep it up. Can u kindly do a tutorial on an oop login system? That will be awesome.Thanks
Very Nice work beautiful flow of concepts...amazing It helped me A LLoT :)
Hello 👋 I'm used to using PDO on database handling, I just wanted to know what is better to use, mysqli or PDO? Thx.
They are both good, obviously if your using my SQL it's better to use the dedicated mysqli handler, but PDO will work just as fine.
Great video! However one thing is not clear to me: why not assign the values to the private variables straight away and not in the "connect" function? Thanks!
Sir I am creating a register and login system using php object oriented approach however I've already created it in procedural style. What I am confusing at is is it necessary to use $conn = new mysqli() inside a connect() function ? can't we use it write is outside that connect function by creating constants instead of variables and then extend the Dbh class and use the $conn directly with prepared statement ?
nice. why do use classes instead of functions to query the db? i struggle with the seperation logic. thx,
Hi, do you have a tutorial for PHP OOP CRUD? thank you. I liked your videos
nice tutorial
Hi, Where the rest of the tutorial ,are you done?. Very useful....thanks man.
In which folder is the database stored? Is it in the same folder where you store your php files, or do you create a subfolder like when you do to put CSS, JS or images for example, or is it somewhere else?
I’m not sure I understand the question. In the video I show that I save the dbh file inside a ‘includes’ folder. If you mean the database we create inside phpmyadmin, then it gets stored somewhere inside our XAMPP installation, and is not something you need to worry about. 🙂
thanks
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.
Great tutorial thanks. What packages are you using for php?
I really like your teaching style! Can you make a register and login system plus email activation for php oop?
I was wondering if you could integrate this into your login-system video :) I would love to see how OOP could be used that way.
I have planned to do so in the future ;)
Is this still on your list? I really look forward to that video!
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?
hey does this vedio belong to any playlist or its just a random vedio?
Nice video!
Are you going to continue with this series? Maybe you can make a long video where we can see the advantage of OOP PHP well. You have given the example of a login system in the last episodes. We know how to make a login system from the normal PHP tutorial series. But maybe you can make a video about it in OOP PHP. And point out the way you need to do it in OOP PHP and the advantage more than the login system itself.
Hi there, yes I will continue this series once I get the time for it. A login system in OOP is the plan for the next episode :)
please! Thank you so much!
looking forward to this!
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
Hi, great stuff, I have a question, if I want create a separate file for SQL credential how the variables are collected by db connect class
could you make videos about how to make a design for files, classes, folders? How should we divide codes into files?
What determines the choice of which type of connection to use between Mysqli and PDO ?
Thank you sir.. this helps me a lot as a student.
Nice tutorial. Could you focused more on OOP PHP rather than html/CSS? Also do you take donation?
I have plans on developing further on OOP PHP once I'm settled in properly after moving :) I gratefully accept donations on my website www.mmtuts.net
I thought you did a great job teaching OOP. Can you let me know what editor you use for PHP?
He's using Sublime Text
sup man....awesome tutorials. But are you done? Where the rest of the tutorial @ lol.
Good day sir Nice tutorial . . Can i put my connection to database in __construct method or not ?? just wondering so it will be automatically connected :D ??
pls make tuts for PDO..
nice
Ah! procedural was much easier to write the connection! Is there any harm in using procedural way to write connection and write all other in OOP?
How do i output only one column? not in the function code but in HTML.
Fore example:
I want one html field to output name, second to output id.
i get all the rows in one field if i use the above method.
Could "viewUser" be a method within "User" class instead of object "viewUser" that extends "User" class?
I'm sorry if this is a stupid question but, can you really run it without error without "?>" in the end of a
Yes as long as there is only PHP :)
In newer versions of PHP, yes
Sir please create CRUD application with OPP and Ajax concept please
Why these older lessons aren't in oop php playlist?
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; ???
Hello sir do u have a video on how to create food product inventory with database?
Wondering where you get all your content to make these video tutorials? What is your source?
Back from when I was studying my bachelor in web development, and some paid online courses :)
Was wondering why use the properties in the dbh class if there is nothing set in this example. Can use enter the properties directly when creating the $conn object. But I'm guessing you want to explain it in an OOP fashion where later some values can be put in the connect function.
It's a good habit to keep sensitive info private. If I were to include the database info directly in the $conn, then the info would be protected and not private. Since we only want to make it possible to access this info in the Dbh class.
Why don't you use a constructor within the dhb class?
Hi,
Your lessons are really helpful. Thank you for your work!
Maybe anybody can clarify a little thing to me. I have done everything the same as in video, but when I try to check result - each element from DB returns 2 times. Where can be a mistake?
Thank you in advance.
very good tutorial mate.
though one thing isn't very clear to me. Why create a new class ViewUser which extends the User class, and why not using the same User class for both methods getAllUsers() and showAllUsers()?
thanks!
We are separating the two classes because we want to have one class which handles all database queries, and another class that shows the data on the website. It is perfectly possible to do it the way you are suggesting, but because we are following the OOP MVC design pattern, we are separating the functionalities.
oh right! we're following the MVC pattern, thanks!
nc tutorial :D
Thank you :)
i want a video for how can i insert items in data base in oop php ? plz
I apologize for being such a newbie but I understand that this connection file is kept in a includes folder. Now i have a file called login.php and register.php which need that connection information. I put at the top of these files the include reference to this connection information file. However when i now try to use this connection information in both of these files i get a undefined variable for $conn. What am I missing?
That seems odd since the $conn should be accesible inside the login and register files. Try checking that you spell everything correctly and included the file path in the correct way.
Hey can you please help I am get an error call to a member function fetch() in the while loop
Waiting for oop mvc mysqli project??
so the "." keyword stands for "+" because I am confused I always use java.
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.
Plz make a video login system in oops
The order of your include files doesn't matter as long you call its methods and properties afterwards.
Last time I checked the order does matter when you include them in your header, otherwise the class files can't refer to one another.
@@Dani_Krossing Oh yes, you are right l overlooked that one class extends the other.
So I think in javascript the order doesn't matter but in PHP it does. However I'm not sure about javascript too. The simplest way is to try it out. Perhaps you know how Javascript reacts if one do not care about the order of included javascript classes.
Can we display mysqli error in inherit class insert?
lf yes how
You don't close the connection? How it works if you want to manage transactions?
According to PHP.net it closes the connecting automatically. Which is why I leave it out in my tutorials.
How to make logout session for all files
Can someone give me some tips on how to insert data using this method? I've been toying around with it for some time, but I haven't had any luck so far
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);
this->username ==> $this->username
how do you update records? Is it something liked... $sql = UPDATE from user WHERE id = 1? I like to update my emailactivation to 1...
UPDATE user SET--------- THEN YOU USE THE WHERE statement
playlist link please...!!
Great tutorial series, learnt loads so far. I'm getting an error message at the end of this one. Not sure where I've gone wrong. Gone through it several times. Any thoughts anyone?
"Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\OOP_12\includes\viewuser.inc.php on line 7"
Make sure you have some data in the table. If not, the method getAllUsers won't have any return and so you'll get that error.
@@matheusalencar6708 Where to use a key with ELSE
echo "No record found!";
Please use naming conventions. don't use getAllUsers, use getUsers, that way you can add an optional "limit" parameter so you don't overwhelm your database retriving 9 million users at once, name your users variable "users" because it contains User instances (not really because you didn't use class mapping, but it should), that way you know what the variable contains. If you name it "datas", fuck knows what's in that variable, plus you could have another variable with the same generic ass name later in your code.
how about: $database->query(SELECT * FROM users); ?
That is also a possible way to query :) However it is using PDO and not MySQLi like mentioned in the video title. In a later episode I go over PDO connections as well since PDO and MySQLi both have pros and cons ;)
Slim course?
No there will be more episodes. I'm currently moving and don't have my office for recording before the weekend.
Gotcha, keep it up!