Тёмный

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

Dani Krossing
Подписаться 483 тыс.
Просмотров 116 тыс.
50% 1

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

Опубликовано:

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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 RU-vid. 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 ));
@ehepatoupatrick7511
@ehepatoupatrick7511 3 года назад
Thanks a lot, everything worked on my side
@Born2DoubleUp
@Born2DoubleUp 2 года назад
would love to see more on PDO!
@tokbunthoeun1488
@tokbunthoeun1488 6 лет назад
Could you please make video about Magic Method in php? Because I love the way your teach.
@lawrencemichael5571
@lawrencemichael5571 4 года назад
BRILLIANT BRILLIANT BRILLIANT! THANK YOU MY MAN! YO DA BEST!
@BogdanGabrielMarinica
@BogdanGabrielMarinica 6 лет назад
Been looking for this exact subject on your channel! Thanks
@jeetenzhurlollz8387
@jeetenzhurlollz8387 6 лет назад
man your tutorials are so awesome
@roman222k
@roman222k 4 года назад
Cool content, thanks a lot mate! That's what I need. Following!
@nikolasblues270
@nikolasblues270 6 лет назад
Just in time! Thank u again! Like before even watch the video! :D
@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.)
@alessandrop1984
@alessandrop1984 5 лет назад
Always a big fan of yours!
@MrSinha
@MrSinha 6 лет назад
Do you know Python? If Yes, then please make tutorials on Python..Many people want to learn python
@jeromekarldayaon7816
@jeromekarldayaon7816 5 лет назад
This course is awesome thank you very much my boy!
@AlineFloresDelon
@AlineFloresDelon 5 лет назад
thank you so much! i'm your big fan now!
@MohamadMohamad-ch5rb
@MohamadMohamad-ch5rb 6 лет назад
My duty has done , hit like and go 😅
@austrisotersons-andersons2450
@austrisotersons-andersons2450 6 лет назад
Great tutorial series, very well explained and easy to understand. Keep up the good work!
@Awesomedariness
@Awesomedariness 6 лет назад
these tutorials are near perfect .. keep up the good work :)
@Vincent-fs8ry
@Vincent-fs8ry 6 лет назад
Great video really help Me thanks Man keep up with great content!
@benjaminhoppe334
@benjaminhoppe334 3 года назад
Great Video! Can you maybe say something how to close this pdo connection?
@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
@elizavetawallace4356
@elizavetawallace4356 5 лет назад
Thank you so much!!! Very helpful
@ramonmoreno152
@ramonmoreno152 6 лет назад
thank you so much for your tutorials!!
@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.
@RSTao77432
@RSTao77432 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 )"??
@khamisyahya1489
@khamisyahya1489 Год назад
Hello deni I want to ask some question about programing. To help me in it
@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 :)
@boyhagawak2757
@boyhagawak2757 5 лет назад
Hi, can you please explain where is the closing connection part?
@nainen5337
@nainen5337 6 лет назад
I love you and your videos!
@developerenn
@developerenn 4 года назад
Hi, I have PHP 5.2.4 will PDO work on my server?
@assad.rajab-2
@assad.rajab-2 4 года назад
Guys i can't find the Playlist of this Tutorial. could anyone post the link
@donaldsingh7647
@donaldsingh7647 4 года назад
Thanks. It would be great if you could also set an option to make a one-time donation to support you...
@mishenthakshana3407
@mishenthakshana3407 3 года назад
Thankyou
@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 :)
@tentpolesman
@tentpolesman 4 года назад
Cool!
@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? 😅
@mariamontesba7235
@mariamontesba7235 6 лет назад
Thank you 👌👌👌👌
@fabianl1156
@fabianl1156 4 года назад
Make this same tutorial, but with SQL Server. Please 🙏.
@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!
@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
@cleancodez
@cleancodez 6 лет назад
laravel please am also waiting men i like your content men,
@brianhide6294
@brianhide6294 5 лет назад
Could not find driver Guys help me, how to fix this
@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...
@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?
@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
@matejhopp7529
@matejhopp7529 4 года назад
Is pdo working on xamp?
@olegs77
@olegs77 6 лет назад
after checking there is still error of empty properties. -----------Fatal error: Uncaught Error: Cannot access empty property-----
@MadaMediaproduction
@MadaMediaproduction 6 лет назад
Any help with this case
@telemarqueernest3687
@telemarqueernest3687 6 лет назад
thank you
@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 !!!
@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
@luciorodrigues3589
@luciorodrigues3589 6 лет назад
Amazing !!!
@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.
@_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!
@ronaldcsjohnson4790
@ronaldcsjohnson4790 3 года назад
Someone please give the link for the complete playlist.
@Dani_Krossing
@Dani_Krossing 3 года назад
It's on my channel page :)
@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.
@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...
@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! :)
@molidaloeung428
@molidaloeung428 5 лет назад
Laravel please!!
Далее
НЮША УСПОКОИЛА КОТЯТ#cat
00:43
Просмотров 642 тыс.
PHP For Beginners, Ep 17 - PDO First Steps
14:25
Просмотров 20 тыс.
PDO Crash Course (PHP)
45:35
Просмотров 277 тыс.
mysql connection and query with php
19:48
Просмотров 11 тыс.
Pong & Object Oriented Programming - Computerphile
12:51
How to Connect to a Database by Using PHP PDO
10:18
Просмотров 15 тыс.
How to connect to MySQL database using PDO
12:38
Просмотров 10 тыс.
PHP Functions Tutorial - Learn PHP Programming
15:32
Просмотров 89 тыс.
Object Oriented PHP
26:37
Просмотров 322 тыс.
НЮША УСПОКОИЛА КОТЯТ#cat
00:43
Просмотров 642 тыс.