PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Feb 23, 2020 12:39 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jul 16, 2012 3:35 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za
I am creating three different classes to handle 3 database actions (deleting, editing, adding). I've decided to create a multi-dimensional array with all the required fields of each table, fields of each form needed.
Syntax: [ Download ] [ Hide ]
<?php
 $data = array(
'tracks' => array(
'fields'  => array('control_no', 'track_name', 'track_length',     // will be used to create the form, names & id values
  'alias', 'area', 'province', 'country',
  'contact_name', 'contact_number', 'email_address',
  'web_address', 'track_map', 'directions', 'web_page',
),                                     
'tooltips' => array('Control number', 'Track name', 'Track length (in meters)',     // tool tips for each field
        'Known as', 'Track area', 'Track province',
        'Track country', 'Contact person', 'Contact number',
        'Email address', 'Web address', 'Track map',
        'Directions', 'Web page',
),
// fields for specific table here
),
// etc
?>

The above element is for data related to the "Tracks" option, the application will work with a few "options", tracks, riders to name just two. I would pass an argument to the object and based on this argument create a form for the specific option or create an edit form or delete the record.

I don't want to re-create this array in each of the classes but i'm not sure how to go about making it available to all 3 classes. Defining it as a constant doesn't work, something about scalar values the error message said so i'm thinking of creating a "base" class from which these 3 classes would extend and thus making the property available to all child classes. Is my approach valid or should i take a different route?

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
PostPosted: Mon Jul 16, 2012 4:15 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
I don't get why you want three classes for three actions. And another thing: why does the "delete" class need the full array? As for editing, can you edit all the fields or just a subset?


Top
 Profile  
 
PostPosted: Mon Jul 16, 2012 5:10 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group