| | #1 |
| Arthur Join Date: 2014
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
| Hi there, Is this real that I can connect one time to mysql using PDO? I mean is that right to do that? If I use the autoloader and I call every time the DATABASE class I'm connecting every time when I call to database class? |
| |
| | #2 |
| Bananas are Yellow! Registered Member War Room Member Join Date: 2013 Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4 |
Yes, PDO is the layer you should be using: PHP: PDO - Manual |
| Put MY voice on YOUR video: AwesomeAmericanAudio.com | |
| |
| | #3 | |
| Arthur Join Date: 2014
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
| |
| |
| | #4 |
| Bananas are Yellow! Registered Member War Room Member Join Date: 2013 Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4 |
PHP offers several database abstraction layers, of which, PDO is generally recommended.
|
| Put MY voice on YOUR video: AwesomeAmericanAudio.com | |
| |
| | #5 | |
| Arthur Join Date: 2014
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
The second question: if I make DATABASE class using PDO and I call everytime to this class so I reconnect everytime to DB? | |
| |
| | #6 | ||
| Bananas are Yellow! Registered Member War Room Member Join Date: 2013 Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4 |
![]()
In my own software, I connect to the database once at the beginning of the PHP invocation, then I pass the open database handle to any function that needs it, and finally close it ("$db = NULL;") at the very end. | ||
| Put MY voice on YOUR video: AwesomeAmericanAudio.com | |||
| |
| | #7 | ||
| Arthur Join Date: 2014
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
PHP Code: | ||
| |
| | #8 |
| Bananas are Yellow! Registered Member War Room Member Join Date: 2013 Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4 |
OK. So you're good to go.
|
| Put MY voice on YOUR video: AwesomeAmericanAudio.com | |
| |
|
| Bookmarks |
| Tags |
| connection, pdo, time |
| |