last time my friend teach me a lil bit of php...
but he teach me using his library and now i realize that i cannot use like $db->sql_fetchrowset() $db->sql_query()
is it possible all pros here teach me how to make class $db?
thanks
how to make class $db?
Moderator: General Moderators
- Peter Anselmo
- Forum Commoner
- Posts: 58
- Joined: Wed Feb 27, 2008 7:22 pm
Re: how to make class $db?
What your friend was probably using (and what I use in my scripts) is what is called a "singleton" database class. Basically, once you define the class, it allows you to execute queries all over the place in your code without having to worry about whether or not you've called the mysql_connect() function already. It'll automatically open a connection if you haven't yet, and if you have, it will keep from opening multiple redundant connections.
....................
I'm not sure if that made any sense or not. If it did, I can explain more, but if it didn't, I would advise forgetting it and using three simple functions for a while for your database work.
mysql_connect()
mysql_select_db()
mysql_query()
....................
I'm not sure if that made any sense or not. If it did, I can explain more, but if it didn't, I would advise forgetting it and using three simple functions for a while for your database work.
mysql_connect()
mysql_select_db()
mysql_query()