Пример #1
0
 function get_column_names($table_name)
 {
     static $table_defs;
     if (isset($table_defs[$table_name])) {
         return $table_defs[$table_name];
     }
     $table_defs[$table_name] = AMP::getDbcon()->MetaColumnNames($table_name);
     return $table_defs[$table_name];
     #AMP_cache_set( AMP_REGISTRY_SYSTEM_DATASOURCE_DEFS, $definedSources );
 }
Пример #2
0
 function testDestroyAssociatedRecords()
 {
     $c = new Company();
     $c->set(array('name' => 'destroy_test'));
     $c->save();
     $p = new Project();
     $p->set(array('company_id' => $c->id, 'name' => 'destroy_project_test'));
     $p->save();
     $e = new Estimate();
     $e->set(array('project_id' => $p->id, 'name' => 'destroy_estimate_test'));
     $e->save();
     $h = new Hour();
     $h->set(array('estimate_id' => $e->id, 'name' => 'destroy_hour_test'));
     $h->save();
     $ch = new Charge();
     $ch->set(array('company_id' => $c->id, 'name' => 'destroy_charge_test'));
     $ch->save();
     $con = new SupportContract();
     $con->set(array('company_id' => $c->id, 'name' => 'destroy_contract_test'));
     $con->save();
     $sup_hr = new Hour();
     $sup_hr->set(array('support_contract_id' => $con->id, 'description' => 'destroy_support_hour_test'));
     $sup_hr->save();
     $pay = new Payment();
     $pay->set(array('company_id' => $c->id, 'name' => 'destroy_payment_test'));
     $pay->save();
     $deleted_items = array('company' => $c->id, 'project' => $p->id, 'estimate' => $e->id, 'hour' => $h->id, 'support_hour' => $sup_hr->id, 'charge' => $ch->id, 'support_contract' => $con->id, 'payment' => $pay->id);
     $c->destroyAssociatedRecords();
     $c->delete();
     $dbcon = AMP::getDb();
     foreach ($deleted_items as $table => $id) {
         if ($table == 'support_hour') {
             $table = 'hour';
         }
         $sql = 'SELECT * FROM ' . $table . ' WHERE id = ' . $id;
         if ($records = $dbcon->Execute($sql)) {
             $this->assertEqual($records->RecordCount(), 0, "{$table} not deleted correctly: %s");
         } else {
             trigger_error($dbcon->ErrorMsg());
         }
     }
 }
Пример #3
0
 function _getColumnNames($sourceDef)
 {
     return @AMP::get_column_names($sourceDef);
 }
Пример #4
0
 function _getColumnNames($sourceDef)
 {
     return AMP::get_column_names($this->dbcon, $sourceDef);
 }
Пример #5
0
 function create($attributes = array(), $class_name = null)
 {
     if (!$class_name) {
         $context = debug_backtrace();
         trigger_error('class name not included for call to ' . __FUNCTION__ . ' on ' . $debug_backtrace[0]['class']);
         return false;
     }
     $item = new $class_name(AMP::getDb());
     $item->mergeData($attributes);
     return $item;
 }
Пример #6
0
 function getLookup($field, $use_sort = false)
 {
     $set = array();
     if (!$this->makeReady()) {
         $sql = "SELECT " . $this->getIdFieldLookups() . ", {$field} " . $this->_makeSource() . $this->_makeCriteria();
         if ($use_sort) {
             $sql .= $this->_makeSort();
         }
         $set = $this->dbcon->CacheGetAssoc($sql);
         AMP::debug_sql($sql, get_class($this) . ' lookup');
         if (!$set && ($db_error = $this->dbcon->ErrorMsg())) {
             trigger_error(sprintf(AMP_TEXT_ERROR_LOOKUP_SQL_FAILED, get_class($this) . __FUNCTION__, $db_error) . $sql);
         }
     } else {
         while ($record = $this->getData()) {
             $set[$record['id']] = $record[$field];
         }
     }
     return $set;
 }
Пример #7
0
function getDbcon()
{
    return AMP::getDbcon();
}