public function SyncWithDimension($sender, $param) { $cleanmodul = ''; $SQL = "SELECT * FROM " . $this->Tedsend_tabelle->Text . " WHERE parent_id" . $this->Tedsend_tabelle->Text . " = " . $this->Tedsend_id->Text; $cleanmodul = preg_replace("/(^t[a-z]\\_)/", "", $this->Tedsend_tabelle->Text); preg_match("/(_[a-z])/", $cleanmodul, $matches); if (count($matches) >= 1) { $cleanmodul = preg_replace("/(_[a-z])/", ucfirst(substr($matches[1], 1, 1)), $cleanmodul); } $finderclass = ucfirst($cleanmodul) . "Record"; $AllRecordsToWrite = TActiveRecord::finder($finderclass)->findAllBySql($SQL); $fieldToTransfer = $this->Tedsend_field->Text; if (count($AllRecordsToWrite) > 0) { foreach ($AllRecordsToWrite as $SingleRecord) { $criteria = new TActiveRecordCriteria(); $criteria->Condition = 'idta_stammdaten_group = :stammdaten_group AND stammdaten_key_extern = :key_extern'; $criteria->Parameters[':stammdaten_group'] = $this->Tedidta_stammdaten_group->Text; $criteria->Parameters[':key_extern'] = $this->Tedsend_tabelle->Text . $SingleRecord->{'id' . $this->Tedsend_tabelle->Text}; $RecordToChange = StammdatenRecord::finder()->find($criteria); if (count($RecordToChange) == 0) { $RecordToChange = new StammdatenRecord(); } $RecordToChange->idta_stammdaten_group = $this->Tedidta_stammdaten_group->Text; $RecordToChange->stammdaten_key_extern = $this->Tedsend_tabelle->Text . $SingleRecord->{'id' . $this->Tedsend_tabelle->Text}; $RecordToChange->stammdaten_name = $SingleRecord->{$fieldToTransfer}; $RecordToChange->save(); unset($RecordToChange); } } }
public function suggestUser($sender, $param) { // Get the token $token = $param->getToken(); // Sender is the Suggestions repeater $mySQL = "SELECT idtm_user,user_name FROM tm_user WHERE user_name LIKE '%" . $token . "%'"; $sender->DataSource = PFH::convertdbObjectSuggest(TActiveRecord::finder('UserRecord')->findAllBySQL($mySQL), array('idtm_user', 'user_name')); $sender->dataBind(); }
public function suggestOrganisation($sender, $param) { // Get the token $token = $param->getToken(); // Sender is the Suggestions repeater $mySQL = "SELECT idtm_organisation,org_name,org_vorname FROM tm_organisation WHERE org_name LIKE '%" . $token . "%'"; $sender->DataSource = PFH::convertdbObjectSuggest(TActiveRecord::finder('OrganisationRecord')->findAllBySQL($mySQL), array('idtm_organisation', 'org_name', 'org_vorname')); $sender->dataBind(); }
function test_find_by_sql_arb() { $sql = 'SELECT c.name as category, i.name as item FROM items i, categories c WHERE i.category_id = c.category_id LIMIT 2'; $items = TActiveRecord::finder('SqlTest')->findBySql($sql); $sql = "SELECT users.*, 'hello' as another_value FROM users LIMIT 2"; $users = TActiveRecord::finder('UserRecord2')->findBySql($sql); var_dump($users); }
function test_finder_throw_exception_when_save() { $obj = TActiveRecord::finder('BaseRecordTest'); try { $obj->save(); $this->fail(); } catch (TActiveRecordException $e) { $this->pass(); } }
public static function finder($className = __CLASS__) { return parent::finder($className); }
/** * @return TActiveRecord corresponding relationship foreign object finder instance. */ public function getForeignRecordFinder() { return TActiveRecord::finder($this->getForeignRecordClass()); }
/** * @return TActiveRecord Active Record finder instance */ protected function getRecordFinder() { return TActiveRecord::finder($this->getRecordClass()); }
function test_finder_returns_same_instance() { $obj1 = TActiveRecord::finder('BaseRecordTest'); $obj2 = TActiveRecord::finder('BaseRecordTest'); $this->assertSame($obj1, $obj2); }
public function getStartNode($idtm_user, $modul, $planungssicht = 0) { //hier muss noch eine pruefung hin, wenn es mehrere treffer gibt... if (count(BerechtigungRecord::finder()->find('idtm_user = ? AND xx_modul = ?', $idtm_user, $modul)) > 0) { return BerechtigungRecord::finder()->find('idtm_user = ? AND xx_modul = ?', $idtm_user, $modul)->xx_id; } else { $SQL = "SELECT id" . $modul . " FROM " . $modul . " WHERE parent_id" . $modul . " = 0"; if ($planungssicht > 0) { $SQL .= " AND idta_stammdatensicht = " . $planungssicht; //gilt nur für die planung } $SQL .= " LIMIT 1"; $cleanmodul = preg_replace("/(^t[a-z]\\_)/", "", $modul); preg_match("/(_[a-z])/", $cleanmodul, $matches); if (count($matches) >= 1) { $cleanmodul = preg_replace("/(_[a-z])/", ucfirst(substr($matches[1], 1, 1)), $cleanmodul); } $finderclass = ucfirst($cleanmodul) . "Record"; $Result = TActiveRecord::finder($finderclass)->findBySql($SQL); if (count($Result) >= 1) { $tmp = "id" . $modul; return $Result->{$tmp}; } else { return 1; } } }