multiple insert

Status
Not open for further replies.
hi all .. I found a way to insert records but I only works by inserting a single row. with plugin php form php code can be entered, then import a table with dates of one year and the sregistros what I want to create in this way I can create using a subquery to insert records. so looks in mysql INSERT INTO insertact (date_time, field1, field2, date, date1) select now (), '1 'as field1, '1' as field2, dates as far, as dates date1 Between dates from dates where '2013 / 04/01 'and '2013 / 04/04'.
the problem is that the entry cuendo form plugin so
$ db = & JFactory :: getDBO ();
$ query = "INSERT INTO insertact (date_time, field1, field2, date, date1) select 'field1 {}', '{field2}', '{date}', '{date1}' from dates where dates between '{date } 'and' {date1} '";
$ db-> setQuery ($ query);
return $ db-> loadResult ();
as I said just inserts the first record.
leave a picture of how it is configured the plugin.
appreciate your help
 
I'm sorry but I really can't understand what you are asking.

And ... what are all the {} for in that query?

Maybe if you write your question in your native language, and I use Google translation, that might help.

-- hugh
 
hola cheesegrits lo que quiero hacer es usar el plugin php de un formulario para crear multiples inserciones de datos en una tabla. lo que tengo hoy dia (no en fabrik) es una pagina php con un formulario para ingresar los datos y en una segunda pagina php se ejecuta esta consulta INSERT INTO agenda_act (id_agen,profesional,fech_act,cant_act,us,seg_ing,tar) SELECT '$id_agen' as id_agen,usuarios.NOMBRE, fechas as fech_act, '1' as cant_act, '$us' as us, now() as seg_ing,'$tar' FROM usuarios, fechas,numero WHERE usuarios.NOMBRE= '$prof' and fechas between '$fech_ini' and '$fech_fin' and numero BETWEEN '1' and '$cant' ORDER BY fech_act asc . esta consulta se crea a partir de una tabla con las fechas de los a?os, los numeros para crear la cantidad de registros individuales.
lo que hace es lo siguiente:
1. tengo que crear un registro por cada actividad en cada dia ( una agenda de actividades)
2.A esa actividad asignarle el nombre de la persona que las debe realizar.

se que se puede realizar con un for pero me ha funcionado con esta consulta sin problemas durante mucho tiempo y pues la verdad no pude realizar el for con cada fecha ya que aveces segun la cantidad de actividades se oueden crear dos o mas actividades el mismo dia.

lo que quiero que me explique es como puedo crear un formulario en fabrik que permita ejecutar esa sentencia mysql para insertar los datos. lo que estaba probando lo vi en un post en el foro pero no me funciona, las llaves son los nombres d elos campos y asi funciona para insertar un solo registro.

gracias por su ayuda


Hi cheesegrits what I do is use the php plugin to create multiple form inserts data into a table. what I have today (not fabrik) is a php page with a form to enter data and a second php page executes this query INSERT INTO agenda_act (id_agen, professional, fech_act, cant_act, us, seg_ing, tar) SELECT '$ id_agen' as id_agen, usuarios.NOMBRE, dates as fech_act, '1 'as cant_act,' $ us 'as us, now () as seg_ing,' $ tar 'FROM users, dates, usuarios.NOMBRE WHERE number =' $ prof 'and date between' $ fech_ini 'and' $ fech_fin 'and number BETWEEN '1' and '$ qty' ORDER BY fech_act asc. this query is created from a table with the dates of the years, the numbers to create the number of individual records.
what it does is the following:
1. I have to create a record for each activity in each day (a calendar of activities)
2.A this activity assign the name of the person who must perform.

it can be done with a for but it has worked with this query without problems for a long time and because the truth could not perform for each second date because sometimes the amount of activities oueden create two or more activities the same day .

I want to explain to me is how I can create a form in fabrik enforce that judgment allowing mysql to insert data. what I saw was testing in a post on the forum but it does not work, the keys are the names d elos fields and also works to insert a single record.

thanks for your help
 
also to run the query you should replace:

Code:
return $db->loadResult ();

with

Code:
return $db->query();
 
Hi Rob thanks issue resolved I put the entire query and a screenshot of the properties of the plugin if someone else helps

$db = & JFactory :: getDBO ();
$query = "INSERT INTO insertact (date_time, fecha,fecha1,fecha2,servicio) select now()as date_time, 1, '{fecha1}', '{fecha2}','{servicio}' from fechas where fechas between '{fecha1}'and'{fecha2}'";
$db-> setQuery ($query);
return $db->query();

Pantallazo-9.png
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top