/** * Build a data definition from a pre-existing table. This is used * to intelligently alter tables that have already been installed. * * @param string $table The name of the table to get a data definition for. * @return array|null */ function getDataDefinition($table) { // make sure the table exists if (!$this->tableExists($table)) { return array(); } // check if we have a cached version of this table description. if (expSession::issetTableCache($table)) { return expSession::getTableCache($table); } $res = @mysqli_query($this->connection, "DESCRIBE `" . $this->prefix . "{$table}`"); $dd = array(); for ($i = 0; $i < mysqli_num_rows($res); $i++) { $fieldObj = mysqli_fetch_object($res); $field = array(); $field[DB_FIELD_TYPE] = $this->getDDFieldType($fieldObj); if ($field[DB_FIELD_TYPE] == DB_DEF_STRING) { $field[DB_FIELD_LEN] = $this->getDDStringLen($fieldObj); } $dd[$fieldObj->Field] = $field; } // save this table description to cache so we don't need to go the DB next time. expSession::setTableCache($table, $dd); $this->query_time('getDataDefinition'); return $dd; }