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

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

Dani Krossing

7 лет назад

159,950 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Joshua Musalia
Joshua Musalia - 08.05.2023 15:36

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.

Ответить
RB
RB - 01.03.2023 15:59

Would using fetch_assocAll() have worked in place of the loop getAllUsers()?

Ответить
GibGab
GibGab - 18.12.2022 01:58

The first video that I've watched that actually helped me understand oop ;) thank you so much

Ответить
محمد & mohammed
محمد & mohammed - 24.11.2022 18:58

thanks that's so helpful

Ответить
dani dan
dani dan - 12.07.2022 11:10

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?

Ответить
Dj Kad aka MC
Dj Kad aka MC - 10.05.2022 15:18

You don't close the connection? How it works if you want to manage transactions?

Ответить
Coding Neko
Coding Neko - 22.03.2022 20:32

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.

Ответить
Marc-Lester Comia
Marc-Lester Comia - 30.11.2021 09:38

clear and concise!

Ответить
August Bloom
August Bloom - 03.05.2021 05:52

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

Ответить
August Bloom
August Bloom - 03.05.2021 05:52

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

Ответить
𝐒𝐢𝐦𝐛𝐀
𝐒𝐢𝐦𝐛𝐀 - 08.03.2021 14:48

hey does this vedio belong to any playlist or its just a random vedio?

Ответить
End One
End One - 23.02.2021 03:37

so the "." keyword stands for "+" because I am confused I always use java.

Ответить
Justine Castillo
Justine Castillo - 21.02.2021 17:17

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.

Ответить
Shankar Anand
Shankar Anand - 09.11.2020 15:47

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 ?

Ответить
dudonz
dudonz - 30.09.2020 01:33

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.

Ответить
Flavious Correia
Flavious Correia - 10.07.2020 13:02

Really useful now i find programming interesting thanks :)

Ответить
Marco Alvarado
Marco Alvarado - 21.06.2020 14:43

Why don't you use a constructor within the dhb class?

Ответить
Jevgenijs Marcenkovs
Jevgenijs Marcenkovs - 17.06.2020 18:35

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.

Ответить
DevAdas
DevAdas - 24.05.2020 01:23

thanks

Ответить
chandan joshi
chandan joshi - 22.05.2020 22:54

Can we display mysqli error in inherit class insert?
lf yes how

Ответить
Jan Siska
Jan Siska - 03.05.2020 20:21

Could "viewUser" be a method within "User" class instead of object "viewUser" that extends "User" class?

Ответить
Thato J. Chere
Thato J. Chere - 01.05.2020 15:28

What determines the choice of which type of connection to use between Mysqli and PDO ?

Ответить
Gabriel Soares
Gabriel Soares - 12.04.2020 05:52

Hello, man. I'm from Brazil and I love your videos. You're so good. Congrats, teacher.

Ответить
GloTech Computing
GloTech Computing - 25.03.2020 14:53

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);

Ответить
Mr Smigz
Mr Smigz - 19.03.2020 17:15

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; ???

Ответить
Ido l
Ido l - 25.02.2020 20:26

playlist link please...!!

Ответить
Ernest Sakala
Ernest Sakala - 15.02.2020 12:25

Hey can you please help I am get an error call to a member function fetch() in the while loop

Ответить
Rifat Beigh
Rifat Beigh - 14.02.2020 21:39

You are an amazing teacher... love the way you make it so simple to understand

Ответить
Stefan Lutu
Stefan Lutu - 29.01.2020 21:41

dsfsd

Ответить
Hank Hightower
Hank Hightower - 13.01.2020 00:11

The sound of your voice always makes me very happy. I love your videos!

Ответить
Hippo T
Hippo T - 18.12.2019 19:43

Why so many classes?

Ответить
mindustrial
mindustrial - 11.11.2019 16:02

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.

Ответить
yayin
yayin - 05.11.2019 02:14

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

Ответить
devnull
devnull - 01.11.2019 19:06

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.

Ответить
Viper
Viper - 29.09.2019 05:48

could you add error message on your connection ?

Ответить
Ankish Ankish
Ankish Ankish - 28.09.2019 15:50

what is "user" here → $sql = "SELECT * FROM user";

Ответить
cloudeweb
cloudeweb - 23.09.2019 13:33

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!

Ответить
Flawless Proudmoore
Flawless Proudmoore - 22.09.2019 07:08

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!

Ответить
Sumit P. Makwana
Sumit P. Makwana - 09.09.2019 16:57

How $data[ ] = $row works?

Ответить
Er1c Sebasta
Er1c Sebasta - 23.08.2019 00:10

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.

Ответить
Ree Jay Anigan
Ree Jay Anigan - 12.08.2019 05:23

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?

Ответить
Hamza Arshad
Hamza Arshad - 25.07.2019 02:29

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

Ответить
Diamond Troller
Diamond Troller - 21.07.2019 22:26

Why these older lessons aren't in oop php playlist?

Ответить
Sourav Dutt
Sourav Dutt - 19.07.2019 14:30

Amazing video 💯👍🙏

Ответить
Learn With Joy
Learn With Joy - 13.07.2019 14:46

why database name and table name is static

Ответить
Architector
Architector - 29.06.2019 15:40

thanks for ur knowledge

Ответить
Jande Fajardo
Jande Fajardo - 18.06.2019 12:00

Hi, do you have a tutorial for PHP OOP CRUD? thank you. I liked your videos

Ответить
Lok Mann
Lok Mann - 22.05.2019 13:33

Plz make a video login system in oops

Ответить
Bernard Balansag
Bernard Balansag - 17.05.2019 13:25

Thank you sir.. this helps me a lot as a student.

Ответить