Update several tables in the same plugin

atamashi

New Member
Hi,
I tried to upgrade three tables in a single plugin. I only work the update. I placed first, the next two do not work. I have swapped positions and have verified that only in the first I have of me // works echo $ query-> dump (); exit; I missing? : O I'm doing wrong? Thank you for your help. This is the code:

Code:
<?php
// Cheque para asegurar que este archivo se incluye en Joomla!
defined('_JEXEC') or die();

// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);

// Here I have code that calculates // variables for update

//
// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_calidad'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_medios_pedidos_rechazados')
->set("Por Tel='$porTel', Por email='$porEmail', Personalmente='$personal'")
->where('id IS NOT NULL');
$db->setQuery($query);
//echo $query->dump();exit;
$db->execute();

// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_calidad'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_tipos_pedidos_rechazados')
->set("Neurolog?a='$neurologia', Neurocirug?a='$neurocirugia', Medicina Interna='$medicinaInterna',
Neuropediatr?a='$neuropediatria', Fisiatr?a='$fisiatria', Psicolog?a='$psicologia',
Neuropsicolog?a='$neuropsicologia', Psiquiatr?a='$psiquiatria', Otro tipo de Cita='$otroTipoCita'")
->where('id IS NOT NULL');
$db->setQuery($query);
$db->execute();

// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_calidad'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_motivos_pedidos_rechazados')
->set("No Disponibilidad Citas='$noDisponCitas', No atendemos especialidad='$noAtendEspecialidad',
No atendemos el motivo='$noMotivoConsulta', Paciente rechaza por excesiva espera='
$pacienteRechazExcesivaEspera', Otro motivo de Rechazo='$otroMotivoRechazo'")
->where('id IS NOT NULL');
$db->setQuery($query);
$db->execute();

?>
 
There are several things wrong with that. Most obvious one is, where are your $neurologia, $neurocirugia etc variables getting set?

Is that supposed to be data posted from the form?

Also, you are referencing table column names with spaces in them, like "No Disponibilidad Citas". Column names can't have spaces in them. They will be the 'name' assigned to them in your Fabrik elements.

-- hugh
 
Hello,
to be more didactic and rethink my question more clearly:
I have the following table:
tabla%20inicial.png

and I access it using the code:
Code:
defined('_JEXEC') or die();

// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);

// Clear down any previous query
$query->clear();
$query
->select(array('medio_del_pedido',
'tipo_de_cita_rechazada',
'motivo_del_rechazo'))
->from('pedidos_rechazados')
->where('tipo_de_cita_rechazada IS NOT NULL');
// Assign the query to the db
$db->setQuery($query);
//siempre antes del ejecute, para obtenerlo y probarlo con phpMyAdmin con mysql
$db->execute();

// Load the results as an array of objects.
$rows = $db->loadObjectList();

to fill the following summary tables:

tablas%20resumen.png

I tried to upgrade three tables in a single plugin.
And only works the first update, but the next two updates do not work.
I have swapped positions and have verified that only in the first was worked my code echo $ query-> dump (); exit;
I missing? : O I'm doing wrong? Thank you for your help. This is the code:

Code:
// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_medios_pedidos_rechazados'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_medios_pedidos_rechazados')
->set("Por Tel='$porTel', Por email='$porEmail', Personalmente='$personal'")
->where('id IS NOT NULL');
$db->setQuery($query);
//echo $query->dump();exit;
$db->execute();

// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_tipos_pedidos_rechazados'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_tipos_pedidos_rechazados')
->set("Neurolog?a='$neurologia', Neurocirug?a='$neurocirugia', Medicina Interna='$medicinaInterna',
Neuropediatr?a='$neuropediatria', Fisiatr?a='$fisiatria', Psicolog?a='$psicologia',
Neuropsicolog?a='$neuropsicologia', Psiquiatr?a='$psiquiatria', Otro tipo de Cita='$otroTipoCita'")
->where('id IS NOT NULL');
$db->setQuery($query);
//echo $query->dump();exit;
$db->execute();

// Clear down any previous query
$query->clear();
// Update the query to my summary table 'carta_motivos_pedidos_rechazados'
// in the fields excelente, muy_bueno, bueno, regular, malo.
$query
->update('carta_motivos_pedidos_rechazados')
->set("No Disponibilidad Citas='$noDisponCitas', No atendemos especialidad='$noAtendEspecialidad',
No atendemos el motivo='$noMotivoConsulta', Paciente rechaza por excesiva espera='
$pacienteRechazExcesivaEspera', Otro motivo de Rechazo='$otroMotivoRechazo'")
->where('id IS NOT NULL');
$db->setQuery($query);
echo $query->dump();exit;
$db->execute();

Thanks for the guidance you can give me!
 
ok, and I found my error. In the SET clause of the query, I must place
set ("Label Summary = '$ sumario1, ...";
but
set ("elemento_de_sumario = '$ sumario1, ...";
Thank you very much, friends, and learned!
 
Yup, as I said in my last reply:

Also, you are referencing table column names with spaces in them, like "No Disponibilidad Citas". Column names can't have spaces in them. They will be the 'name' assigned to them in your Fabrik elements.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top