Hi again,
i got a question concerning OOP, would be nice if anyone could help. I am trying to build a class that builds SQL statements dynamically like i send tablenames, fieldnames, etc and it should build select, insert, update... statements. e.g. i have a table PERS_DATA with following structur : ID | FIRSTNAME varchar(40) | LASTNAME varchar(40) | REGISTRATION date | AGE int (5) (sure it makes no sence to save the age but itīs an example) Now i want to save postdata of a registerform in this table and it should work like this : $query_obj = new sql_class('insert','PERS_DATA',$postvars); $db_obj = new db_class(); $db_obj -> query ($query_obj -> sql); sql_class should instance a check_persdat_postvars_class that sends me a predefined error in case the entries of the form where wrong (age not numeric for example) Now the sql class would have to build a insertstatement like this : $fields = ""; $vals = ""; $i=0; while ( list ( $key,$val ) = each ( $param_arr ) ) { if (!empty($i)) { $fields .= ','; $vals .= ','; } $fields .= $key; $vals .= $val; $i++; } $this -> SQL = "insert into $table ($fields) values ($vals)"; but elements of $vals 'can' be strings and some can be numeric... Do you think itīs a good idea to make queries to find out about fieldtypes as i need that info to set quotes for the string entries? Or do you think i should predefine it instead in the class that checks the postvars? Or do you think i have a absolute stupid idea? Tia regards Jochen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php