This is some working code for archiving from one Table into another.
This is for archiving, not for cloning.
I'm using Variables Variables to step through different qcodo lstObjects and dump all their information from the database directly into an archive table with mysql features.
This workes fast and convenient.
The archive table has an additional primary field and a key field to the original table. This is of course for the relation between those tables.
The keyfield identifies the archive table (can also be uniquely identified by only writing the first part of the key, but I use a concatinated string for the fun of it and it works well).
$this->arrPersonen = array("lstZugehoerigkeitObjektObject",
"lstZugehoerigkeitAbgeberObject","lstZugehoerigkeitKundeObject","lstZugehoerigkeitZubringerAbgeberObject","lstZugehoerigkeitZubringerKundeObject",
$objDatabase = QApplication::$Database[1];
for ($r=0;$r<sizeof($this->arrPersonen);$r++)
{
if ($this->{$this->arrPersonen[$r]}->SelectedValue!=NULL)
{
$strQuery = "SELECT * FROM `PersonenArchiv` WHERE PersonenArchiv.key='".$this->lblId->Text."X".$this->{$this->arrPersonen[$r]}->SelectedValue."'";
$objDbResult = $objDatabase->Query($strQuery);
if ($objDbResult->CountRows()<1)
{
$strQuery = "INSERT INTO `PersonenArchiv` SELECT '','".$this->lblId->Text."X".$this->{$this->arrPersonen[$r]}->SelectedValue."',Personen.* FROM `Personen` WHERE Personen.id='".$this->{$this->arrPersonen[$r]}->SelectedValue."'";
$objDbResult = $objDatabase->Query($strQuery);
}
}
}
So using an attribute with variables variables works like this:
$this->{$this->arrPersonen[$r]}->SelectedValue
All the Best,
tronics