CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Programmically change tables used in form for upate insert delete

Print topic Send  topic

Author Message
telmiger

Posts: 61
Posted: 07/19/2016, 5:43 PM

I am trying to build a multi lingual site.

I have several navigation tables, menu_de, menu_fr ,menu_en
In my menu and grid I was able to use in the BeforeExecuteSelect event to set my table name depending on my on the language selected.
$my_menu->Menu1->DataSource->SQL = "SELECT * FROM menu_fr";

In my form i can use the same statement in the BeforeExecuteSelect event and if I edit a menu record the proper information is displayed in the form depending on the language selected.
But when I hit update, the record in the table that I used to build the form is updated menu_en and not my menu_fr table that I selected with the language selection.

Does anybody know on how to change the table selection in the form for the update/inserte/delete operation by custom code?

Tony
View profile  Send private message
DataDoIT
Posted: 07/19/2016, 6:20 PM

Why not use the built-in internationalization features of CodeCharge?
telmiger

Posts: 61
Posted: 07/19/2016, 8:07 PM

I do use the internationalization for all the field labels that I have in my application.
Since I am storing my menu links in tables I am switching the tables at run time depending on the language selection.

I am not sure how else to implement this.
View profile  Send private message
eratech


Posts: 513
Posted: 07/19/2016, 10:21 PM

I agree with DataDoIT - there are probably better ways of handling this.

However, as you have the code in the BeforeExecuteSelect, you can probably do a similar thing in the BeforeInsert, BeforeUpdate and BeforeDelete actions, so the table is changed then.

The BeforeExecuteSelect would probably only work on the Select.

I would also suggest making it a function that you can refer to all over the place, pass in the correct language and the object that needs changing, and it does the update. You could add the function at the end of Common.php or I use a separate Utility.php and include it in Common.php.

Cheers

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
DataDoIT
Posted: 07/20/2016, 6:28 AM

Rather than having a unique table per language, just add a field to your
menus table for the internationalization codes (ie: en, fr, de). Then
you can still reference the CCSLocales component and pull the applicable
translation record where needed.

switch (CCGetSession("locale","")) {
case "en":
//
break;
case "fr":
//
break;
}

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.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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