Hi,
I need some help on updating database records. I need to allow the user edit a particular field in multiple records in the table depending upon some another field.
I have used the DB Multi Record Loader which get the data from the table depending upon the first field as I desired.
Now, How do I use this data to edit the multiple records on one go i.e. single submit of the form.🙄
Thanks in advance...
I need some help on updating database records. I need to allow the user edit a particular field in multiple records in the table depending upon some another field.
I have used the DB Multi Record Loader which get the data from the table depending upon the first field as I desired.
Now, How do I use this data to edit the multiple records on one go i.e. single submit of the form.🙄
Thanks in advance...
Hi pintu,
You can use several DB Save actions if the column names are distinct; otherwise you may have to hand-code some of the MySQL queries.
Bob
You can use several DB Save actions if the column names are distinct; otherwise you may have to hand-code some of the MySQL queries.
Bob
Hello GreyHead,
Many thanks for the suggestions. Just one clarification, since the no. of rows returned by DB Multi Record holder will vary, how can I use several DB Save while designing the form. Is there any way around?
Many thanks for the suggestions. Just one clarification, since the no. of rows returned by DB Multi Record holder will vary, how can I use several DB Save while designing the form. Is there any way around?
Hi pintu,
If there are a variable number of inputs then I'd use array names for that group of form inputs and then a hand-coded PHP foreach loop to manage the array results and create the necessary MySQL queries to save them.
Bob
If there are a variable number of inputs then I'd use array names for that group of form inputs and then a hand-coded PHP foreach loop to manage the array results and create the necessary MySQL queries to save them.
Bob
Hi Bob and Pintu.
I've got the same problem that Pintu but I think I'm a bit confuse on how to solve the multiple records saving.
I've got a table and I want to save multiple rows at the same time (in the same form). As I unterstand, the DB save can't save multiple rows, but only one.
I've found the code you have write Bob, but I just don't know what changes to make it works for me.
Did I need to make a loop (set the data aray and make the query) until I have saved all the rows, or should I make an array for each entrie (one array by column)?
What would you code if you must save two articles for example?
Thanks you
Flo
I've got the same problem that Pintu but I think I'm a bit confuse on how to solve the multiple records saving.
I've got a table and I want to save multiple rows at the same time (in the same form). As I unterstand, the DB save can't save multiple rows, but only one.
I've found the code you have write Bob, but I just don't know what changes to make it works for me.
<?php
$data = array();
$data['cf_id'] = 99;
$data['name'] = 'John Smith';
$record =& JTable::getInstance("chronoforms_newsletter_signup", "Table");
if ( !$record->save($data) ) {
JError::raiseWarning(100, $record->getError());
}
if (!class_exists('Tablechronoforms_newsletter_signup')) {
class Tablechronoforms_newsletter_signup extends JTable
{
var $cf_id = null;
var $uid = null;
var $recordtime = null;
var $ipaddress = null;
var $cf_user_id = null;
var $name = null;
var $email = null;
function __construct( &$database ) {
parent::__construct( '#__chronoforms_newsletter_signup', 'cf_id', $database );
}
}
}
?>
Did I need to make a loop (set the data aray and make the query) until I have saved all the rows, or should I make an array for each entrie (one array by column)?
What would you code if you must save two articles for example?
Thanks you
Flo
Hi!
I've set the following code in the On submit event:
But I've got the result here, in an error message :
and debugger results :
I have tested on PhpMyAdmin and the table db_joom25_c.jooc_content is ok.
What do I miss?
Thanks
Flo
I've set the following code in the On submit event:
<?php
if (!class_exists('Tablecontent')) {
class Tablecontent extends JTable
{
var $id = null;
var $title = null;
var $catid = null;
var $state = null;
var $access = null;
var $created = null;
var $introtext = null;
function __construct( &$database ) {
parent::__construct( 'jooc__content', 'id', $database );
}
}
}
$count = 2;
for ($i = 1; $i <= $count; $i++) {
$data = array();
$intext="input_text_".$i;
$data['title'] = $intext;
$data['catid'] = 21;
$data['state'] = 1;
$data['access'] = 2;
$data['created'] = gmdate("Y-m-d H:i:s");
$data['introtext']=$form->data[$intext];
$record =& JTable::getInstance("content", "Table");
if ( !$record->save($data) ) {
JError::raiseWarning(100, $record->getError());
}
}
?>
But I've got the result here, in an error message :
Tablecontent: :store échoué
La table 'db_joom25_c.jooc__content' n'existe pas SQL=INSERT INTO `jooc__content` (`title`,`catid`,`state`,`access`,`created`,`introtext`) VALUES ('input_text_1','21','1','2','2013-03-24 22:23:42','essai1')
Tablecontent: :store échoué
La table 'db_joom25_c.jooc__content' n'existe pas SQL=INSERT INTO `jooc__content` (`title`,`catid`,`state`,`access`,`created`,`introtext`) VALUES ('input_text_2','21','1','2','2013-03-24 22:23:42','essai2')
and debugger results :
Warning: Invalid argument supplied for foreach() in C:\Program Files\EasyPHP-12.1\www\essai_joomla_chrono\libraries\joomla\database\database\mysql.php on line 383
Warning: Invalid argument supplied for foreach() in C:\Program Files\EasyPHP-12.1\www\essai_joomla_chrono\libraries\joomla\database\database\mysql.php on line 383
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => multidbsave
[event] => submit
[Itemid] =>
[input_text_1] => essai1
[input_text_2] => essai2
[input_submit_3] => Submit
[f104552936bb19cbd9a79e997205a551] => 1
)
Validation Errors:
Array
(
)
I have tested on PhpMyAdmin and the table db_joom25_c.jooc_content is ok.
What do I miss?
Thanks
Flo
This topic is locked and no more replies can be posted.