/** * Given a type and an id, instantiate a record * If no id given, instantiate a new empty record of type, using the right class for this record type * For instance if it is a multilingual table, it will return a multilingual record object (@todo) * **/ function newRecord($table, $id = false, $data = false) { // will include the right module class if needed, for example, specialized modules like ftp datasource // currently the base module is used if ($table != '') { // optimization : file is required on top of this class file // optimization removed, because no real speed impact found // find if the record has a locale field $multilingual = false; if (isset($this->config['table'][$table]['field'])) { foreach ($this->config['table'][$table]['field'] as $field) { if ($field['type'] == 'locale') { $multilingual = true; } } } if ($multilingual) { require_once 'record.multilingual.class.php'; $record = new record_multilingual($table); } else { require_once 'record.class.php'; $record = new record($table); } if ($id) { $record->set('id', $id); } if ($data) { $record->loadByArray($data); } return $record; } else { trigger_error('thinkedit::newRecord() $table not defined'); } }
/** * Given a type and an id, instantiate a record * If no id given, instantiate a new empty record of type, using the right class for this record type * For instance if it is a multilingual table, it will return a multilingual record object (@todo) * **/ function newRecord($table, $id = false, $data = false) { // will include the right module class if needed, for example, specialized modules like ftp datasource // currently the base module is used if ($table != '') { // optimization : file is required on top of this class file require_once 'record.class.php'; $record = new record($table); if ($id) { $record->set('id', $id); } if ($data) { $record->loadByArray($data); } return $record; } else { trigger_error('thinkedit::newRecord() $table not defined'); } }