CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

  Join 2 fields and store it in another PHP & MySQL

Print topic Send  topic

Author Message
vartron


Posts: 7
Posted: 07/31/2014, 5:37 PM

I have a record called xxyyzz, I need to join 2 or more fields and store them in a 3rd.

EXAMPLE.
Field 1 = Name
Field 2 = Name2
Field 3 = Name + Name2

All this before sending to save.

Sorry for my English
View profile  Send private message
saseow

Posts: 744
Posted: 07/31/2014, 9:01 PM

Try something like this:

In the On Validate event of the record form join the strings with PHP like:
$Container->Field3->SetValue($Container->Field1->GetValue()." ".$Container->Field2->GetValue());

That should work.
View profile  Send private message
eratech


Posts: 513
Posted: 08/01/2014, 3:46 AM

Or the same code in the
Before Insert
or
Before Update
events for the Record.

saseow - any reason you do it in the Validation instead of Before Update etc?

E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
laneoc

Posts: 154
Posted: 08/01/2014, 12:42 PM

Or use a trigger.
_________________
Lane
View profile  Send private message
saseow

Posts: 744
Posted: 08/01/2014, 9:53 PM

No real reason why I would put it in On Validation other than laziness eratech. Before Insert is fine but I would also put it in Before update in case any of the single fields used was changed so a little more work to do. Using a trigger is also fine except requires a bit more typing.
Just laziness :-/
View profile  Send private message
eratech


Posts: 513
Posted: 08/03/2014, 3:06 AM

You are right - you need to add it into both Update and Insert.

Was really just wondering if there was anything special, but laziness is something I can relate to. :-)

Lane - a trigger would work, but I've steered away from DB triggers as they don't always travel well between DBs and it kind of hides the logic away in the DB.

cheers

E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
vartron


Posts: 7
Posted: 08/05/2014, 7:03 AM

Thank you very much, I did in the events, but I require to do the same in a custom insert or a custom update, with expressions. Can i do this.

Actually I require concatenate 2 ID and the last record ID. Do I require from a custom insert.

Example.
Control 1: 1
Control 2: 2
Metadata: 1-2-last_record_id

that's my problem.
Tks. to all
View profile  Send private message
saseow

Posts: 744
Posted: 08/05/2014, 9:49 PM

You can also join fields in an SQL statement using 'CONCAT' or 'CONCAT_WS'.
Google that and you will find tons of examples.
View profile  Send private message
sorinbuda

Posts: 27
Posted: 06/03/2016, 11:49 AM

Quote saseow:
Try something like this:

In the On Validate event of the record form join the strings with PHP like:
$Container->Field3->SetValue($Container->Field1->GetValue()." ".$Container->Field2->GetValue());

That should work.


That example works well in a Record but I can not make it work in a Editable Grid.
Do you have any idea why?
I already tried OnValidate, OnValidateRow at the EditableGrid level and OnValidate at the field level.

kind regards,
Sorin
View profile  Send private message
sorinbuda

Posts: 27
Posted: 06/03/2016, 12:57 PM

Solved with SQL in Custom Update
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.