You are not logged in.
Pages: 1
Hello everyone,
I'm currently writing a website with PHP and MySQL.
I would like to know which strategy you choose to manage database connection.
I did not find any way to have a database connection pooling in PHP like I usally use in J2EE.
My current strategy is some kind of singleton my front controller will share with all "sub controller".
So, to render a page, I'll have a single static connection ( using PDO ). Opened at the beginning and closed at the end of the page.
So, what do you use in your PHP webapps?
Regards.
Shaika-Dzari
http://www.4nakama.net
Offline
Up!
No one are creating their our database connection business?
Are you using zend, pear or something?
Regards.
Shaika-Dzari
http://www.4nakama.net
Offline
I am using the Zend Framework, but have you already read the Zend Framework Quickstart? There are a few often needed components explained, also the database connection.
Offline
My current strategy is some kind of singleton my front controller will share with all "sub controller".
This.
Open just on the start of the page though, collect all data in an object, close the connection and then print out.
ᶘ ᵒᴥᵒᶅ
Offline
Open just on the start of the page though, collect all data in an object, close the connection and then print out.
Care to give me an example, or point me to an online example of this?
I'm merely an amateur, and don't understand things like 'singletons' - I do think that I currently code in MVC, but I would like to know more about design patterns. When it comes to db-connections, I think I open the connection, load all the needed data and close the connection. Don't know whether I 'collect the data in an object', though
Offline
Care to give me an example, or point me to an online example of this?
If you have a class that makes a database connection, making it a singleton is a way to construct it only once and then reuse it throughout your project without having to create new instances. So the singleton basically is just a class (with a bit of extra code), and an instance of a class is called an object.
Here is an example of how to create a singleton in PHP: http://en.wikipedia.org/wiki/Singleton_pattern#PHP
ᶘ ᵒᴥᵒᶅ
Offline
litemotiv wrote:Open just on the start of the page though, collect all data in an object, close the connection and then print out.
Care to give me an example, or point me to an online example of this?
I'm merely an amateur, and don't understand things like 'singletons' - I do think that I currently code in MVC, but I would like to know more about design patterns. When it comes to db-connections, I think I open the connection, load all the needed data and close the connection. Don't know whether I 'collect the data in an object', though
If you search a very good book, my suggestion is:
http://www.amazon.com/Objects-Patterns- … 982&sr=8-1
Seriouly, a must have!
Open just on the start of the page though, collect all data in an object, close the connection and then print out.
Great to see I'm not completely wrong
but have you already read the Zend Framework Quickstart?
Yep, I know Zend. But I want to create something without any framework to learn and improve my php knowledge.
Shaika-Dzari
http://www.4nakama.net
Offline
Pages: 1