Thread: The SQL Class
View Single Post
Old 12-30-2008, 04:26 AM   #3 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
A good class, but some revisions need to be made.

-Please use allman style indentation to conform to project standards.
-For setHandler, do not use an array to pass paramaters, just pass multiple paramaters.
-Have connect assign the connection to a variable so we can pass it to other functions that need database interactions.
-Don't have it use a seperate function to set a query, just have the command functions accept a text parameter to the commend from. I work with a set command then execute it method in asp at work, its a pain.

Those are all rather small things, other then what I named above, its a good class.
- Allman style is what?
- I thought it would be better to have it an array, cause then you can assign the parameters at different locations. For example someone might want to process some data to decide which table to select(remember that this SQL class is actually a wide-use class, so it's not really designed specificly for THIS project). Trying to keep it general, so people can re-use it for other projects. But if it's neccessary, we can change that.
- I'm not sure I follow. I have it assigned to $this->con, and I use it in other functions aswell.
- As I said, I'm trying to make things general. Someone might want to assign a query, but not execute it before something has happend. However, to do what you want, I designed the exeQuery to accept an SQL statement, so to execute a query is simply done like this:
PHP Code:
$db->exeQuery("DELETE * FROM `table` WHERE `col` = '3'");
// or if you're selecting something, you want to retrieve the query:
$query $db->exeQuery("SELECT * FROM `table`")->getQueryResult(); 
But, if you really want, I could design the getQueryResult to accept a SQL statement, so you only have to call 1 function to do a query AND retrieve the results. However, I find it unneccessary to return a query result when you're for example deleting something. It's useful when retrieving a list, or a specific row. That's why I think it should have the option to actually only execute a query and not return anything, and the option to execute a query and retrieve the results.

But that's me..
__________________
Tanax is offline  
Reply With Quote