primary key as part of an other field value

faitas 25 Apr, 2016
Hi, I am trying to write some data in the database using the primary key ['cf_id'] as part of it.
So, on confirm i placed this custom code:
<?php
$form->data['link'] = "some text {$form->data['area']} {$form->data['cf_id']}";
?>


The result of it is that I see it on the debugger as
[link] => some text 32 59
but I do not see it written in the database under the field [link] !!

would appreciate some help please.
GreyHead 25 Apr, 2016
Hi faitas,

Is this the Primary Key of the newly created record? That doesn't exist before the DB Save is made so you'd have to use a second DB Save to update the value afterwards.

Bob
faitas 27 Apr, 2016
I do not fully understand you statement. sorry😟

this is a newly created record and when I save it, I want to add the primary key [cf_id] in an other field.
faitas 27 Apr, 2016
I will give it a second try.... I have placed this piece of code after email verification. so the item has been saved and the cf_id created beforehand.
faitas 04 May, 2016
no luck. any idea ?
GreyHead 04 May, 2016
Hi faitas,

Please explain exactly what you are trying to do here.

Bob
faitas 04 May, 2016
I am trying to create a link to each form entry and place it in the db table for reference.
In order to do that I need to add the cf_id at the end of a text, like that: http://www.some-page.com/?code={cf_id}
GreyHead 05 May, 2016
Hi faitas,

OK.

a. I wouldn't do it that way, the record id is available from a DB Read so I'd build the URL when it is needed. There's a basic principle of database design that says 'don't save the same data twice'.

b. As I said before the cf_id isn't available until after the first DB Save so you would need to use a second DB Save to update the record and add the link.

Bob
This topic is locked and no more replies can be posted.