Jump to content

Convert db fields to "pretty names"


RopeADope

Recommended Posts

So, if you have TableA with a column named ID that you would like to label: 'User id' and TableB with a column named ID that you would like to label: 'Product id', how would this one single list of labels work?

 

You could make all your column names unique, but that is just making unnecessary work for yourself.

 

Whatever you do, you need to keep it general purpose, so that once you test it, you can forget about it, rather than needing to keep track of an ever increasing amount of information as the size of an application grows. Oops, I change an entry in this array to match what I needed this code to do and my code on that page over there now needs to be retested because they were tied together too closely and weren't general purpose enough.

Link to comment
Share on other sites

Here's what's in my en.php so far.

<?php

$__TEXT__=array
(
   /* Achievements Table */
   'achievements'=>"Achievements",
   'achievements_id'=>"Achievements ID",
   'date'=>"Date",
   'employee'=>"Employee",
   'achievement'=>"Achievement",
   'description'=>"Description",
   'date_of_occurence'=>"Date of Occurence",
   'skills_developed'=>"Skills Developed",
   'sponsor'=>"Sponsor",
   'comments'=>"Comments",
   /* Activity Details Table */
   'activity_details'=>"Activity Details",
   'activity_details_id'=>"Activity Details ID",
   'date'=>"Date",
   'activity'=>"Activity",
   'description'=>"Description",
   'comments'=>"Comments",
   /* Actual Table */
   'actual'=>"Actual",
   'actual_id'=>"Actual ID",
   'date'=>"Date",
   'capacity_incidents'=>"Capacity Incidents",
   'capacity_problems'=>"Capacity Problems",
   'capacity_10%'=>"Capacity 10%",
   'optimizations'=>"Optimizations",
   'description'=>"Description",
   'capacity_plan_date'=>"Capacity Plan Date",
   'capacity_plan_summary'=>"Capacity Plan Summary",
   'comments'=>"Comments",
   /* Agreement Activity */
   'agreement_activity'=>"Agreement Activity",
   'agreement_activity_id'=>"Agreement Activity ID",
   'date'=>"Date",
   'agreement_name'=>"Agreement Name",
   'activity'=>"Activity",
   'description'=>"Description",
   'next_step'=>"Next Step",
   'status'=>"Status",
   'comments'=>"Comments",
   /* Agreement Details Table*/
   'agreement_details'=>"Agreement Details",
   'date'=>"Date",
   'type'=>"Type",
   'agreement_name'=>"Agreement Name",
   'party'=>"Party",
   'description'=>"Description",
   'penalties'=>"Penalties",
   'start_date'=>"Start Date",
   'end_date'=>"End Date",
   'owner_1_name'=>"Owner 1",
   'owner_2_name'=>"Owner 2",
   'file_name'=>"File Name",
   'file_location'=>"File Location",
   'comments'=>"Comments",
   /* Availability Table*/
   'availability'=>"Availability",
   'availability_id'=>"Availability ID",
   'date'=>"Date",
   'avail_incid'=>"Incident",
   'avail_unavail'=>"Unavailable",
   'avail_down_pr1'=>"Down PR1",
   'avail_down_pr2'=>"Down PR2",
   'avail_down_pr3'=>"Down PR3",
   'avail_alerts'=>"Alerts",
   'util_unavail'=>"Utilities Unavailable",
   'avail_auto'=>"Availability Auto",
   'avail_proc'=>"Available Processes",
   'comments'=>"Comments",
   /* Strategy Table */
   'strategy'=>"Strategy",
   'strategy_id'=>"Strategy ID",
   'date'=>"Date",
   'bus_strategy'=>"Business Strategy",
   'tech_strategy'=>"Technology Strategy",
   'co_values'=>"Company Values",
   'comments'=>"Comments",
   'mission'=>"Mission",
   'project_approval_board'=>"Project Approval Board",
   'change_mgmt_board'=>"Change Management Board",
   'emergency_change_board'=>"Emergency Change Board",
   'cm_owner'=>"Change Management Owner",
   'cm_alternate'=>"Change Management Alternate",
   'change_window'=>"Change Window",
   /* KEDB Table */
   'kedb'=>"Known Error Database",
   'kedb_id'=>"KEDB ID",
   'date'=>"Date",
   'service'=>"Service",
   'system'=>"System",
   'it_owner'=>"IT Owner",
   'description'=>"Description",
   'impact'=>"Impact",
   'status'=>"Status",
   'resolution'=>"Resolution",
   'close_date'=>"Close Date",
   'comments'=>"Comments",
   /* vCTO Tasks Table */
   'vcto_tasks'=>"vCTO Tasks",
   'vcto_task_id'=>"vCTO Task ID",
   'date'=>"Date",
   'process'=>"Process",
   'task'=>"Task",
   'origination'=>"Origination",
   'assigned_to'=>"Assigned To",
   'status'=>"Status",
   'due_date'=>"Due Date",
   'completed_date'=>"Completed Date",
   'next_steps'=>"Next Steps",
   'comments'=>"Comments"
);

?>

 

The majority of the tables in this application were converted from Access so that's why it has all the weird naming conventions.  I understand your point now about uniqueness of the labels and such.  So my question is this: How do I modify the en.php file in such a way that it's unique to the tables?  Would I have a different array for each table then when I call the build_form function, I'd call it like this:

build_form($table_name,$table_label_array)

?

 

EDIT:  Another thing I thought of is in terms of "setting and forgetting" code.  As the database changes in either table names or field names, I'll still have to change the en.php file to address those changes.  So there really isn't a way to write something once and have it always work...or am I missing something?

Link to comment
Share on other sites

en.php:

<?php
$__TEXT__=array
(
   /* Achievements Table */
   'achievements'=>"Achievements",
   'achievements_id'=>"Achievements ID",
   'date'=>"Date",
   'employee'=>"Employee",
   'achievement'=>"Achievement",
   'description'=>"Description",
   'date_of_occurence'=>"Date of Occurence",
   'skills_developed'=>"Skills Developed",
   'sponsor'=>"Sponsor",
   'comments'=>"Comments",
   /* Activity Details Table */
   'activity_details'=>"Activity Details",
   'activity_details_id'=>"Activity Details ID",
   'date'=>"Date",
   'activity'=>"Activity",
   'description'=>"Description",
   'comments'=>"Comments",
   /* Actual Table */
   'actual'=>"Actual",
   'actual_id'=>"Actual ID",
   'date'=>"Date",
   'capacity_incidents'=>"Capacity Incidents",
   'capacity_problems'=>"Capacity Problems",
   'capacity_10%'=>"Capacity 10%",
   'optimizations'=>"Optimizations",
   'description'=>"Description",
   'capacity_plan_date'=>"Capacity Plan Date",
   'capacity_plan_summary'=>"Capacity Plan Summary",
   'comments'=>"Comments",
   /* Agreement Activity */
   'agreement_activity'=>"Agreement Activity",
   'agreement_activity_id'=>"Agreement Activity ID",
   'date'=>"Date",
   'agreement_name'=>"Agreement Name",
   'activity'=>"Activity",
   'description'=>"Description",
   'next_step'=>"Next Step",
   'status'=>"Status",
   'comments'=>"Comments",
   /* Agreement Details Table*/
   'agreement_details'=>"Agreement Details",
   'date'=>"Date",
   'type'=>"Type",
   'agreement_name'=>"Agreement Name",
   'party'=>"Party",
   'description'=>"Description",
   'penalties'=>"Penalties",
   'start_date'=>"Start Date",
   'end_date'=>"End Date",
   'owner_1_name'=>"Owner 1",
   'owner_2_name'=>"Owner 2",
   'file_name'=>"File Name",
   'file_location'=>"File Location",
   'comments'=>"Comments",
   /* Availability Table*/
   'availability'=>"Availability",
   'availability_id'=>"Availability ID",
   'date'=>"Date",
   'avail_incid'=>"Incident",
   'avail_unavail'=>"Unavailable",
   'avail_down_pr1'=>"Down PR1",
   'avail_down_pr2'=>"Down PR2",
   'avail_down_pr3'=>"Down PR3",
   'avail_alerts'=>"Alerts",
   'util_unavail'=>"Utilities Unavailable",
   'avail_auto'=>"Availability Auto",
   'avail_proc'=>"Available Processes",
   'comments'=>"Comments",
   /* Strategy Table */
   'strategy'=>"Strategy",
   'strategy_id'=>"Strategy ID",
   'date'=>"Date",
   'bus_strategy'=>"Business Strategy",
   'tech_strategy'=>"Technology Strategy",
   'co_values'=>"Company Values",
   'comments'=>"Comments",
   'mission'=>"Mission",
   'project_approval_board'=>"Project Approval Board",
   'change_mgmt_board'=>"Change Management Board",
   'emergency_change_board'=>"Emergency Change Board",
   'cm_owner'=>"Change Management Owner",
   'cm_alternate'=>"Change Management Alternate",
   'change_window'=>"Change Window",
   /* KEDB Table */
   'kedb'=>"Known Error Database",
   'kedb_id'=>"KEDB ID",
   'date'=>"Date",
   'service'=>"Service",
   'system'=>"System",
   'it_owner'=>"IT Owner",
   'description'=>"Description",
   'impact'=>"Impact",
   'status'=>"Status",
   'resolution'=>"Resolution",
   'close_date'=>"Close Date",
   'comments'=>"Comments",
   /* vCTO Tasks Table */
   'vcto_tasks'=>"vCTO Tasks",
   'vcto_task_id'=>"vCTO Task ID",
   'date'=>"Date",
   'process'=>"Process",
   'task'=>"Task",
   'origination'=>"Origination",
   'assigned_to'=>"Assigned To",
   'status'=>"Status",
   'due_date'=>"Due Date",
   'completed_date'=>"Completed Date",
   'next_steps'=>"Next Steps",
   'comments'=>"Comments"
);
?>

 

cn.php:

<?php
$__TEXT__=array
(
   /* Achievements Table */
   'achievements'=>"Achievements",
   'achievements_id'=>"Achievements ID",
   'date'=>"Date",
   'employee'=>"Employee",
   'achievement'=>"Achievement",
   'description'=>"Description",
   'date_of_occurence'=>"Date of Occurence",
   'skills_developed'=>"Skills Developed",
   'sponsor'=>"Sponsor",
   'comments'=>"Comments",
   /* Activity Details Table */
   'activity_details'=>"Activity Details",
   'activity_details_id'=>"Activity Details ID",
   'date'=>"Date",
   'activity'=>"Activity",
   'description'=>"Description",
   'comments'=>"Comments",
   /* Actual Table */
   'actual'=>"Actual",
   'actual_id'=>"Actual ID",
   'date'=>"Date",
   'capacity_incidents'=>"Capacity Incidents",
   'capacity_problems'=>"Capacity Problems",
   'capacity_10%'=>"Capacity 10%",
   'optimizations'=>"Optimizations",
   'description'=>"Description",
   'capacity_plan_date'=>"Capacity Plan Date",
   'capacity_plan_summary'=>"Capacity Plan Summary",
   'comments'=>"Comments",
   /* Agreement Activity */
   'agreement_activity'=>"Agreement Activity",
   'agreement_activity_id'=>"Agreement Activity ID",
   'date'=>"Date",
   'agreement_name'=>"Agreement Name",
   'activity'=>"Activity",
   'description'=>"Description",
   'next_step'=>"Next Step",
   'status'=>"Status",
   'comments'=>"Comments",
   /* Agreement Details Table*/
   'agreement_details'=>"Agreement Details",
   'date'=>"Date",
   'type'=>"Type",
   'agreement_name'=>"Agreement Name",
   'party'=>"Party",
   'description'=>"Description",
   'penalties'=>"Penalties",
   'start_date'=>"Start Date",
   'end_date'=>"End Date",
   'owner_1_name'=>"Owner 1",
   'owner_2_name'=>"Owner 2",
   'file_name'=>"File Name",
   'file_location'=>"File Location",
   'comments'=>"Comments",
   /* Availability Table*/
   'availability'=>"Availability",
   'availability_id'=>"Availability ID",
   'date'=>"Date",
   'avail_incid'=>"Incident",
   'avail_unavail'=>"Unavailable",
   'avail_down_pr1'=>"Down PR1",
   'avail_down_pr2'=>"Down PR2",
   'avail_down_pr3'=>"Down PR3",
   'avail_alerts'=>"Alerts",
   'util_unavail'=>"Utilities Unavailable",
   'avail_auto'=>"Availability Auto",
   'avail_proc'=>"Available Processes",
   'comments'=>"Comments",
   /* Strategy Table */
   'strategy'=>"Strategy",
   'strategy_id'=>"Strategy ID",
   'date'=>"Date",
   'bus_strategy'=>"Business Strategy",
   'tech_strategy'=>"Technology Strategy",
   'co_values'=>"Company Values",
   'comments'=>"Comments",
   'mission'=>"Mission",
   'project_approval_board'=>"Project Approval Board",
   'change_mgmt_board'=>"Change Management Board",
   'emergency_change_board'=>"Emergency Change Board",
   'cm_owner'=>"Change Management Owner",
   'cm_alternate'=>"Change Management Alternate",
   'change_window'=>"Change Window",
   /* KEDB Table */
   'kedb'=>"Known Error Database",
   'kedb_id'=>"KEDB ID",
   'date'=>"Date",
   'service'=>"Service",
   'system'=>"System",
   'it_owner'=>"IT Owner",
   'description'=>"Description",
   'impact'=>"Impact",
   'status'=>"Status",
   'resolution'=>"Resolution",
   'close_date'=>"Close Date",
   'comments'=>"Comments",
   /* vCTO Tasks Table */
   'vcto_tasks'=>"vCTO Tasks",
   'vcto_task_id'=>"vCTO Task ID",
   'date'=>"Date",
   'process'=>"Process",
   'task'=>"Task",
   'origination'=>"Origination",
   'assigned_to'=>"Assigned To",
   'status'=>"Status",
   'due_date'=>"Due Date",
   'completed_date'=>"Completed Date",
   'next_steps'=>"Next Steps",
   'comments'=>"Comments"
);
?>

 

<?php
$lang = $_SESSION['lang']; // en or cn
require_once "languages/$lang.php";
echo "Hello check out your {$__TEXT__['achievements']}";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.