Hello,
I have tried to make a second table connection to update some values, but with no success.
The bind() function returned error no matter what syntax i would use to declare the $data array (or $post).
I have tried to declare a second connection direct, through DBConnection tab. It worked, and it created a new entry in the both tables. When i have removed the connection to the second table from DBConnections tab and copied the autogenerated code for that connection in the "after submit box" the bind() function again returned the error (Call to a member function bind() on a non-object). I have tested also save() function, same result.
I have done your example for coded connection to a table from start to finish. Again non-object error.
All the names of the tables, columns checked. No numbers at start of name, no dashes, no spaces.
Also tried with "JTable" class instead of "Table"
This is the code from the example connection:
<?php
$data = array();
$data['cf_id'] = 1;
$data['name'] = 'John_Smith';
$record =& JTable::getInstance("jos_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( 'jos_chronoforms_newsletter_signup', 'cf_id', $database );
}
}
}
?>
I cannot say if the source of the error is $data or $record.
Can it be some setting in the chronoforms that is causing the problem?
Please help.
Thank you.
I have tried to make a second table connection to update some values, but with no success.
The bind() function returned error no matter what syntax i would use to declare the $data array (or $post).
I have tried to declare a second connection direct, through DBConnection tab. It worked, and it created a new entry in the both tables. When i have removed the connection to the second table from DBConnections tab and copied the autogenerated code for that connection in the "after submit box" the bind() function again returned the error (Call to a member function bind() on a non-object). I have tested also save() function, same result.
I have done your example for coded connection to a table from start to finish. Again non-object error.
All the names of the tables, columns checked. No numbers at start of name, no dashes, no spaces.
Also tried with "JTable" class instead of "Table"
This is the code from the example connection:
<?php
$data = array();
$data['cf_id'] = 1;
$data['name'] = 'John_Smith';
$record =& JTable::getInstance("jos_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( 'jos_chronoforms_newsletter_signup', 'cf_id', $database );
}
}
}
?>
I cannot say if the source of the error is $data or $record.
Can it be some setting in the chronoforms that is causing the problem?
Please help.
Thank you.
Hi lorelainerv,
I'm not sure why you need to do this by copying the code rather than using the DB Connection?
From the error message it looks as though you need to create the class before the code to create a new instance. Just swapping round the code blocks may do it.
Bob
I'm not sure why you need to do this by copying the code rather than using the DB Connection?
From the error message it looks as though you need to create the class before the code to create a new instance. Just swapping round the code blocks may do it.
<?php
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( 'jos_chronoforms_newsletter_signup', 'cf_id', $database );
}
}
}
$data = array();
$data['cf_id'] = 1;
$data['name'] = 'John_Smith';
$record =& JTable::getInstance("jos_chronoforms_newsletter_signup","Table");
if (!$record->save($data)) {
JError::raiseWarning(100, $record->getError());
}
?>
Bob
Thank you for the reply.
I cannot use the DB Connection because it doesnt update *one* value, it just creates a new entry (next cf_id) with the new information.
And i have swapped the declaration code but to no avail.😟
Same error, different row Call to a member function save() on a non-object.
I also tried modifying the run order, since this function works in autogenerated box. Doesnt work.
I cannot see what i am doing wrong.
Can i modify/update a field value (corresponding to a given unique key) through db connection? I have not tried modifying the autogenerated code since I thing that code is refreshet as is every time the form is used.
Thank you.
I cannot use the DB Connection because it doesnt update *one* value, it just creates a new entry (next cf_id) with the new information.
And i have swapped the declaration code but to no avail.😟
Same error, different row Call to a member function save() on a non-object.
I also tried modifying the run order, since this function works in autogenerated box. Doesnt work.
I cannot see what i am doing wrong.
Can i modify/update a field value (corresponding to a given unique key) through db connection? I have not tried modifying the autogenerated code since I thing that code is refreshet as is every time the form is used.
Thank you.
Hi lorelainerv,
If the data you are saving includes the table primary key, usually cf_id if the table was created by ChronoForms, and the value of the primay key field matches an existing record then the record will be updated. If there is no value set, or it doesn't match an existing record then a new record will be created.
Bob
If the data you are saving includes the table primary key, usually cf_id if the table was created by ChronoForms, and the value of the primay key field matches an existing record then the record will be updated. If there is no value set, or it doesn't match an existing record then a new record will be created.
Bob
It worked!
I needed to make the primary key name different for the tables that undergo changes and it worked.
Thank you very much!
I needed to make the primary key name different for the tables that undergo changes and it worked.
Thank you very much!
This topic is locked and no more replies can be posted.