tiagovareta
Member
Hi,
I am using the following code to copy records from one table to 4 other related tables:
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
foreach ($ids AS $myid)
{
$row = $model->getRow($myid);
$id = $row->tb_contactos___id_contacto;
$nome = $row->tb_contactos___nome;
$apelido = $row->tb_contactos___apelido;
$email = $row->tb_contactos___email;
$contribuinte = $row->tb_contactos___contribuinte;
$morada = $row->tb_contactos___morada;
$numero = $row->tb_contactos___numero;
$codigopostal = $row->tb_contactos___codigo_postal;
$localidade = $row->tb_contactos___localidade;
$contacto = $row->tb_contactos___contacto;
$datanascimento = $row->tb_contactos___data_nascimento;
$sponsor = $row->tb_contactos___sponsor;
$data = $row->tb_contactos___data;
$origem = $row->tb_contactos___origem;
$db = FabrikWorker::getDbo(); //Liga??o ? BD APP OriGest
$db2 = FabrikWorker::getDbo(false, 2); //Liga??o ? BD que recebe os contactos da LP
$query = "INSERT INTO tb_contactos_geral (id, nome_ctg, apelido_ctg, contribuinte_ctg, data_nascimento_ctg, sponsor_ctg, data_registo_ctg, origem_ctg) VALUES ('$id', '$nome', '$apelido', '$contribuinte', '$datanascimento', '$sponsor', '$data', '$origem')";
$db->setQuery($query);
$db->execute();
$query1 = "INSERT INTO tb_email (email_eml, id_contacto_geral_eml) VALUES ('$email', '$id')";
$db->setQuery($query1);
$db->execute();
$query2 = "INSERT INTO tb_morada (morada_mrd, numero_porta_mrd, codigo_postal_mrd, localidade_mrd, id_contacto_geral_mrd) VALUES ('$morada', '$numero', '$codigopostal', '$localidade', '$id')";
$db->setQuery($query2);
$db->execute();
$query3 = "INSERT INTO tb_contacto (contacto_ctt, id_contacto_geral_ctt) VALUES ('$contacto', '$id')";
$db->setQuery($query3);
$db->execute();
$query4 = "UPDATE tb_contactos SET registado='1' WHERE id_contacto=$id";
$db2->setQuery($query4);
$db2->execute();
}
Basically I copy a record from the table "tb_contactos", where the fields are distributed to the tables "tb_contactos_geral, tb_email, tb_morada, tb_contacto".
After the copy the main table is: tb_contactos_geral, the relationship with the other tables (tb_email, tb_morada, tb_contacto) is LEFT JOIN.
Until now I think everything is right! Because it copies the record well for all tables.
In the table form "tb_contactos_geral" i'm using the Juser Plugin.
My problem is when I try to edit the record I copied (already in the table tb_contactos_geral).
When I click edit, the information at the top appears:
Alert
JUser: :_load: Could not load user with ID: 9448
When I "save" it gives the error:
1054 Unknown column 'Array' in 'where clause'
Can anyone help me? What could be the cause of this error?
I am using the following code to copy records from one table to 4 other related tables:
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
foreach ($ids AS $myid)
{
$row = $model->getRow($myid);
$id = $row->tb_contactos___id_contacto;
$nome = $row->tb_contactos___nome;
$apelido = $row->tb_contactos___apelido;
$email = $row->tb_contactos___email;
$contribuinte = $row->tb_contactos___contribuinte;
$morada = $row->tb_contactos___morada;
$numero = $row->tb_contactos___numero;
$codigopostal = $row->tb_contactos___codigo_postal;
$localidade = $row->tb_contactos___localidade;
$contacto = $row->tb_contactos___contacto;
$datanascimento = $row->tb_contactos___data_nascimento;
$sponsor = $row->tb_contactos___sponsor;
$data = $row->tb_contactos___data;
$origem = $row->tb_contactos___origem;
$db = FabrikWorker::getDbo(); //Liga??o ? BD APP OriGest
$db2 = FabrikWorker::getDbo(false, 2); //Liga??o ? BD que recebe os contactos da LP
$query = "INSERT INTO tb_contactos_geral (id, nome_ctg, apelido_ctg, contribuinte_ctg, data_nascimento_ctg, sponsor_ctg, data_registo_ctg, origem_ctg) VALUES ('$id', '$nome', '$apelido', '$contribuinte', '$datanascimento', '$sponsor', '$data', '$origem')";
$db->setQuery($query);
$db->execute();
$query1 = "INSERT INTO tb_email (email_eml, id_contacto_geral_eml) VALUES ('$email', '$id')";
$db->setQuery($query1);
$db->execute();
$query2 = "INSERT INTO tb_morada (morada_mrd, numero_porta_mrd, codigo_postal_mrd, localidade_mrd, id_contacto_geral_mrd) VALUES ('$morada', '$numero', '$codigopostal', '$localidade', '$id')";
$db->setQuery($query2);
$db->execute();
$query3 = "INSERT INTO tb_contacto (contacto_ctt, id_contacto_geral_ctt) VALUES ('$contacto', '$id')";
$db->setQuery($query3);
$db->execute();
$query4 = "UPDATE tb_contactos SET registado='1' WHERE id_contacto=$id";
$db2->setQuery($query4);
$db2->execute();
}
Basically I copy a record from the table "tb_contactos", where the fields are distributed to the tables "tb_contactos_geral, tb_email, tb_morada, tb_contacto".
After the copy the main table is: tb_contactos_geral, the relationship with the other tables (tb_email, tb_morada, tb_contacto) is LEFT JOIN.
Until now I think everything is right! Because it copies the record well for all tables.
In the table form "tb_contactos_geral" i'm using the Juser Plugin.
My problem is when I try to edit the record I copied (already in the table tb_contactos_geral).
When I click edit, the information at the top appears:
Alert
JUser: :_load: Could not load user with ID: 9448
When I "save" it gives the error:
1054 Unknown column 'Array' in 'where clause'
Can anyone help me? What could be the cause of this error?