dynamic table - need to generate object on the fly in custom component

For Joomla! 1.0 Coding related discussions.
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 184
Joined: Tue Oct 10, 2006 5:05 pm
Location: Montreal

dynamic table - need to generate object on the fly in custom component

Post by markedagain » Mon Feb 19, 2007 2:45 am

Hey guys,

its my first component in joomla also my first scripts in php. (asp.net is my first language)

i have a contact table where the admin is able to add extra fields from a config area. The rpoblem is i cant seem to figure put how to add the new fields into my mosDBTable class for my custom table. (i know the code is not for 1.5 but i figure you guys could still guide me the right way)

this obviously does not work but it shows what i need to achieve

Code: Select all

class moseasycontacts extends mosDBTable {

		global $database;

                //#__easycontacts_columns contains all field names in our contact table
		$sql = "SELECT * FROM #__easycontacts_columns WHERE section = '$this->tablename' ";
		$field_name = $database->loadObjectList();
		for ($i=0, $n=count($field_name); $i < $n; $i++) {
			$field = $field_name[$i];
			$declare = $field->name . "=null";
			var $$declare;

  * @param database A database connector object
  function moseasycontacts( &$db ) {

    $this->mosDBTable( '#__easycontacts_contacts', 'id', $db );
i know about "Joomla Object Generator" but there is alot of lines of code to understand and customize to my needs, but the whole thing is poorly documented and there are to many files for me to be able to go through in day or two.

is there a simply way to do this or will i have to create a script that rewrites the whole class (table.class.php) with the new objects on the server every time there is a field change  (this means permission problems on secure sites i believe)


Return to “Joomla! 1.0 Coding”