function load($db, $tables, $id = '') { if ($this->_use_db_connection_string) { $this->disco_db_connect(); $this->_db = get_database_name($db); $this->disco_db_disconnect(); } else { $this->_db = $db; } if (is_string($tables)) { $this->tables = array($tables); } else { reset($tables); while (list(, $t) = each($tables)) { $this->tables[$t] = array(); } } $this->_id = $id; $this->load_has_run = true; }
/** * @return array column_name=>column_type * @todo this is old code pulled form discodb and should be reviewed for efficiency */ function &get_database_columns() { if (!isset($this->_database_columns)) { $table = $this->get_table_name(); connectDB($this->get_db_conn()); $types = mysql_query( "show fields from $table" ) OR trigger_error( 'Could not retrieve types from DB' ); $fields = mysql_list_fields( get_database_name(), $table ) OR trigger_error( 'Could not retrieve fields from DB: '.mysql_error() ); $columns = mysql_num_fields( $fields ); connectDB(REASON_DB); for ($i = 0; $i < $columns; $i++) { $f = mysql_field_name($fields, $i) OR trigger_error( 'um ... something is wrong. you should check me. and someone should write a more descriptive error message.' ); $db_type = mysql_result($types, $i,'Type' ) OR trigger_error( 'um ... something is wrong. you should check me. and someone should write a more descriptive error message.' ); $this->_database_columns[$f] = $db_type; } } return $this->_database_columns; }