/** * @ignore */ function doImport(&$config) { $installerPath = __AMBER_BASE__ . '/install/'; $amber =& Amber::getInstance($config); // Create tx_amber_sys_objects $sysDb =& Amber::sysDb(); $sql = file_get_contents($installerPath . '/tx_amber_sys_objects.sql'); if ($sql == false) { echo formatMessage('Unable to open tx_amber_sys_objects.sql'); return false; } $sysDb->Execute($sql); if ($sysDb->ErrorNo() != 0) { echo formatMessage('Importing tx_amber_sys_objects.sql failed:<p />' . $sysDb->ErrorMsg()); } // Create table which hold sample data $db =& Amber::currentDb(); $sql = @file_get_contents($installerPath . '/sample_data.sql'); if ($sql == false) { echo formatMessage('Unable to open sample_data.sql'); return false; } $db->Execute($sql); if ($db->ErrorNo() != 0) { echo formatMessage('Importing sample_data.sql failed:<p />' . $db->ErrorMsg()); } }
function _doQuery() { $db =& Amber::currentDb(); if ($this->RowSourceType == 'Table/Query') { $db->SetFetchMode(ADODB_FETCH_BOTH); $data =& $db->GetAll($this->RowSource); } if (isset($this->BoundColumn)) { // Indexes in Access start with 1 $bound = $this->BoundColumn - 1; } else { $bound = 0; } // FIXME: Determine first visible row -> option value $this->_data = array(); if (is_array($data)) { foreach ($data as $idx => $row) { $this->_data[$row[$bound]] = $row[1]; } } }
/** * * @access protected * */ function _fetchDataFromDatabase() { static $uniqueId = 0; if (empty($this->RecordSource)) { return; } elseif (strtolower($this->RecordSource) == '[array]') { // _data filled in direct (i.e. tests) return; } $db =& Amber::currentDb(); $createdTemporaryTable = false; // Apply where clause $sql = $this->_makeSqlFilter($this->RecordSource, $this->Where); // Select into temporary table if necessary // NOTE: Filter is only implemented for use with MySQL if ($this->Filter != '' && $db->databaseType == 'mysql') { $uniqueId++; $createdTemporaryTable = true; $sql = 'CREATE TEMPORARY TABLE temp' . $uniqueId . ' (' . $sql . ')'; $db->Execute($sql); if ($db->errorNo() != 0) { Amber::showError('Database error while trying to create temporary table (' . $db->ErrorNo() . ')', $db->ErrorMsg()); die; } // Apply filter $sql = 'SELECT * FROM temp' . $uniqueId; $sql = $this->_makeSqlFilter($sql, $this->Filter); } // Get records $recordSet =& $db->Execute($sql); if (empty($recordset)) { if ($db->ErrorNo() != 0) { Amber::showError('Database Error ' . $db->ErrorNo(), $db->ErrorMsg()); die; } } $this->_data =& $recordSet->GetArray(); $recNo = $recordSet->FieldCount(); for ($i = 0; $i < $recNo; $i++) { $fld = $recordSet->FetchField($i); $type = $recordSet->MetaType($fld->type); if ($type == 'L' || $type == 'I' || $type == 'N' || $type == 'R') { $this->_dataIsNumeric[$fld->name] = $type; } else { unset($this->_dataIsNumeric[$fld->name]); } } if ($createdTemporaryTable) { $sql = 'DROP TEMPORARY TABLE IF EXISTS temp' . $uniqueId; $db->Execute($sql); } }