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

  Рет қаралды 116,351

Dani Krossing

Dani Krossing

Күн бұрын

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: code.tutsplus....
➤ SPECIAL THANKS TO THE FOLLOWING PATRONS!
Name: Scooterman
Channel Link: / @scooterman9230
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: / oop-php-lessons-26928726

Пікірлер: 85
@alvin8294
@alvin8294 6 жыл бұрын
It's my first time to take php oop seriously and I find your series more helpful than my instructor. You earn a sub!
@tharushakavishan4720
@tharushakavishan4720 3 жыл бұрын
hey, Dani I from Srilanka. so today I'm a professional web developer and I have a small startup and I have not any college degree my all web developer knowledge learning from you Thank you everything for man
@Born2DoubleUp
@Born2DoubleUp 2 жыл бұрын
I'm here! 😎 Great video, just posting a comment to show some support! Keep up the good work. 🤙
@odunladeoluwaseun7880
@odunladeoluwaseun7880 6 жыл бұрын
I was telling people on the forum yesterday that you are one of the best Php tutor on KZbin. 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
@drcod3r329
@drcod3r329 6 жыл бұрын
please a course about laravel please i want your tutorial sooo bad :)
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
I have it written down :) but it might be a while before I get to it unfortunitaly
@ovidiublaga1
@ovidiublaga1 6 жыл бұрын
Yes, please
@abduljabbardumrai7904
@abduljabbardumrai7904 5 жыл бұрын
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 ));
@BogdanGabrielMarinica
@BogdanGabrielMarinica 6 жыл бұрын
Been looking for this exact subject on your channel! Thanks
@jeetenzhurlollz8387
@jeetenzhurlollz8387 6 жыл бұрын
man your tutorials are so awesome
@tokbunthoeun1488
@tokbunthoeun1488 6 жыл бұрын
Could you please make video about Magic Method in php? Because I love the way your teach.
@nikolasblues270
@nikolasblues270 6 жыл бұрын
Just in time! Thank u again! Like before even watch the video! :D
@austrisotersons-andersons2450
@austrisotersons-andersons2450 5 жыл бұрын
Great tutorial series, very well explained and easy to understand. Keep up the good work!
@jaydee3807
@jaydee3807 6 жыл бұрын
Hi there mate, some great tutorials going on. I was wondering if you could cover in this series Dependency injection which is the preferred option over the singleton pattern when it comes to connecting and accessing the database from lets say the user class? Also some helper methods that would make prepared statements else where easier to implement (query, bind, execute..etc.)
@ehepatoupatrick7511
@ehepatoupatrick7511 3 жыл бұрын
Thanks a lot, everything worked on my side
@osamamughal8010
@osamamughal8010 6 жыл бұрын
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
@lawrencemichael5571
@lawrencemichael5571 4 жыл бұрын
BRILLIANT BRILLIANT BRILLIANT! THANK YOU MY MAN! YO DA BEST!
@roman222k
@roman222k 4 жыл бұрын
Cool content, thanks a lot mate! That's what I need. Following!
@alessandrop1984
@alessandrop1984 5 жыл бұрын
Always a big fan of yours!
@jeromekarldayaon7816
@jeromekarldayaon7816 5 жыл бұрын
This course is awesome thank you very much my boy!
@Awesomedariness
@Awesomedariness 6 жыл бұрын
these tutorials are near perfect .. keep up the good work :)
@Born2DoubleUp
@Born2DoubleUp 2 жыл бұрын
would love to see more on PDO!
@AlineFloresDelon
@AlineFloresDelon 5 жыл бұрын
thank you so much! i'm your big fan now!
@benjaminhoppe334
@benjaminhoppe334 3 жыл бұрын
Great Video! Can you maybe say something how to close this pdo connection?
@Vincent-fs8ry
@Vincent-fs8ry 6 жыл бұрын
Great video really help Me thanks Man keep up with great content!
@MrSinha
@MrSinha 6 жыл бұрын
Do you know Python? If Yes, then please make tutorials on Python..Many people want to learn python
@elizavetawallace4356
@elizavetawallace4356 5 жыл бұрын
Thank you so much!!! Very helpful
@sonnyb6536
@sonnyb6536 6 жыл бұрын
Hey Daniel. How are you? I know this isn't the video about javascript but it is your latest :D. I was hoping you could make different project videos for javascript so I, we all can learn more about it. Like a simple game using javascript, a curtain webpage, idk. Some interactive projects that use html, css and mostly javascript to help learn by doing. Thank you for all your videos!!!
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
Hi Sonny :) I am planning on uploading a new JavaScript lesson today, and in the future create more project focused episodes, since these are the ones I have the most success with.
@sonnyb6536
@sonnyb6536 6 жыл бұрын
Glad to here it Daniel. No worries on when you upload :)
@ramonmoreno152
@ramonmoreno152 6 жыл бұрын
thank you so much for your tutorials!!
@taospencer1403
@taospencer1403 4 жыл бұрын
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 )"??
@nainen5337
@nainen5337 6 жыл бұрын
I love you and your videos!
@tentpolesman
@tentpolesman 4 жыл бұрын
Cool!
@sven2529
@sven2529 4 жыл бұрын
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.
@donaldsingh7647
@donaldsingh7647 4 жыл бұрын
Thanks. It would be great if you could also set an option to make a one-time donation to support you...
@khamisyahya1489
@khamisyahya1489 Жыл бұрын
Hello deni I want to ask some question about programing. To help me in it
@deopurkar
@deopurkar 6 жыл бұрын
Yor are a great turor. Please Make a tutorial on Codeigniter.
@deopurkar
@deopurkar 6 жыл бұрын
Hey you didn't reply, are you going make tutorial or not? 😅
@mishenthakshana3407
@mishenthakshana3407 3 жыл бұрын
Thankyou
@boyhagawak2757
@boyhagawak2757 5 жыл бұрын
Hi, can you please explain where is the closing connection part?
@MohamadMohamad-ch5rb
@MohamadMohamad-ch5rb 6 жыл бұрын
My duty has done , hit like and go 😅
@luciorodrigues3589
@luciorodrigues3589 6 жыл бұрын
Amazing !!!
@mariamontesba7235
@mariamontesba7235 6 жыл бұрын
Thank you 👌👌👌👌
@fabianl1156
@fabianl1156 4 жыл бұрын
Make this same tutorial, but with SQL Server. Please 🙏.
@avinasha3237
@avinasha3237 5 жыл бұрын
Don't you continue the series anymore as there are many concepts in PHP. The way you teach is very good.
@Dani_Krossing
@Dani_Krossing 5 жыл бұрын
Yes I just started continueing this series :)
@cleancodez
@cleancodez 6 жыл бұрын
laravel please am also waiting men i like your content men,
@telemarqueernest3687
@telemarqueernest3687 5 жыл бұрын
thank you
@assad.rajab-2
@assad.rajab-2 4 жыл бұрын
Guys i can't find the Playlist of this Tutorial. could anyone post the link
@developerenn
@developerenn 4 жыл бұрын
Hi, I have PHP 5.2.4 will PDO work on my server?
@ravinishad8424
@ravinishad8424 5 жыл бұрын
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
@klemlloydmwenya2224
@klemlloydmwenya2224 4 жыл бұрын
I have trouble with my PDO connection and I think you can help me. I have DSN values as they should be ```$conn = new PDO("mysql:host = $serverName; dbname = $dbName; charset = $charset", $userName, $password);```, but when I temper with dbname, the connection still succeeds. I want to have a connection to a specific database on my server. But this all thing gets rather confusing when the connection is happening to a database that doesn't even exist.
@klemlloydmwenya2224
@klemlloydmwenya2224 4 жыл бұрын
Let me reach on phone, whatsapp or some thing. I do have a good number of queries!
@richarddunne8036
@richarddunne8036 2 жыл бұрын
I used the same code from this tutorial, however, the pdo connection in my data file, I'm getting Undefined variable for dsn, user and pass. Any idea what could/might be causing this?
@AbdulAzeem-un7hz
@AbdulAzeem-un7hz 2 жыл бұрын
can you please show the query that you are trying to execute?
@_Omni
@_Omni 6 жыл бұрын
Make a tutorial on Blender :D
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
I'd love to once I don't have too many courses going at once :)
@_Omni
@_Omni 6 жыл бұрын
You are the best!
@crazy_coder
@crazy_coder 5 жыл бұрын
can you suggest me how can i connect to another database if one if failed to connect...Please help is anyone read this...
@brianhide6294
@brianhide6294 5 жыл бұрын
Could not find driver Guys help me, how to fix this
@matejhopp7529
@matejhopp7529 4 жыл бұрын
Is pdo working on xamp?
@amarsinghania7080
@amarsinghania7080 6 жыл бұрын
Question about pdo oop So I have a log in system with pdo and oop where after a user logs in, he can see a bunch of info on his profile page in a table. I fetch this info in user.php and set the session variables there and check if session variables are set on profile page and display those session variables data in table there. Is this a good practice to have a bunch of session variable or should I use pdo to run fetch queries instead and forward an array to profile ?
@timmatthews4595
@timmatthews4595 6 жыл бұрын
It would probably be better practice to pass the user id session variable to your user class and have a function fetch all of the profile data for that user and then return this to the profile page in an array. That way you're only using one session variable which is defined outside of the class (and should already be defined to validate authentication etc).
@amarsinghania7080
@amarsinghania7080 6 жыл бұрын
Tim Matthews yeah thats what I did. Thanks !!! Took a bunch of time to figure out how to return a json and then display data in a table created using ajax that converts json to infinite number of table rows depending on how many rows were fetched from the database. Using session variables only for user name verify and display. Rest of the data fetching and mod using pdo statements and separate methods in oop class. Oop php is awesome !!!
@hasnatkabir8903
@hasnatkabir8903 6 жыл бұрын
Is the $password and $username attributes mentatory to pass int PDO (...).Can,t i connect the database without these?
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
We pass them in to keep the database info private to the Dbh class only :) If we include them directly into a protected method, then other classes have access to it as well. Which we don't want.
@ronaldcsjohnson4790
@ronaldcsjohnson4790 3 жыл бұрын
Someone please give the link for the complete playlist.
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
It's on my channel page :)
@stefan4800
@stefan4800 6 жыл бұрын
Do you use Blender for modeling? :)
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
Well I just started using it :) I have more experience using Cinema4D
@stefan4800
@stefan4800 6 жыл бұрын
Cinema4D is really great! :)
@Dexter101x
@Dexter101x 6 жыл бұрын
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
@Dexter101x
@Dexter101x 6 жыл бұрын
Oh I see why, I didn't add the "=" to the dbname and charset bit, bit of a typo
@emornutaz2946
@emornutaz2946 6 жыл бұрын
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
@gen157
@gen157 6 жыл бұрын
Experiencing this as well. I've simply commented it out for now. It worked once with it but kept failing after the fact. Everywhere I look people are using it just fine, but fails on mine.
@AlineFloresDelon
@AlineFloresDelon 5 жыл бұрын
i know it's late, but here is my comment in case anyone else has the same issue, it must say utf8mb4, i had a similar problem that lasted 3 weeks :S
@olegs77
@olegs77 6 жыл бұрын
after checking there is still error of empty properties. -----------Fatal error: Uncaught Error: Cannot access empty property-----
@MadaMediaproduction
@MadaMediaproduction 5 жыл бұрын
Any help with this case
@MrSinha
@MrSinha 6 жыл бұрын
Are you learning machine learning or algorithms of Artificial Intelligence? Please Reply Me.
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
Mr. Sinha No :)
@MrSinha
@MrSinha 6 жыл бұрын
That's Ok! But Your Teaching Skills are very good!
@MrSinha
@MrSinha 6 жыл бұрын
Your videos helped me very much while I was learning PHP.
@molidaloeung428
@molidaloeung428 5 жыл бұрын
Laravel please!!
@zlackbiro
@zlackbiro 5 жыл бұрын
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...
mysql connection and query with php
19:48
Tintu Vlogger
Рет қаралды 11 М.
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 55 МЛН
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 94 МЛН
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 7 МЛН
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 43 МЛН
How to Connect to a Database by Using PHP PDO
10:18
Alex
Рет қаралды 15 М.
Apprendre le PHP : Chapitre 31, PDO
40:53
Grafikart.fr
Рет қаралды 60 М.
What does MySQLi vs PDO Teach You about Development?
13:19
Stefan Mischook
Рет қаралды 11 М.
PHP For Beginners, Ep 17 - PDO First Steps
14:25
Laracasts
Рет қаралды 20 М.
How to connect to MySQL database using PDO
12:38
Patrick Morrow
Рет қаралды 10 М.
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 55 МЛН