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);
         }
     }
 }
예제 #2
0
 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();
 }
예제 #3
0
 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();
 }
예제 #4
0
    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);
    }
예제 #5
0
 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());
 }
예제 #8
0
 /**
  * @return TActiveRecord Active Record finder instance
  */
 protected function getRecordFinder()
 {
     return TActiveRecord::finder($this->getRecordClass());
 }
예제 #9
0
 function test_finder_returns_same_instance()
 {
     $obj1 = TActiveRecord::finder('BaseRecordTest');
     $obj2 = TActiveRecord::finder('BaseRecordTest');
     $this->assertSame($obj1, $obj2);
 }
예제 #10
0
 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;
         }
     }
 }