Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Code Samples vs Generated code

phpMyEdit General     Code Samples vs Generated code
Post new topic   Reply to topic    
 
jpgus     Joined: 04 Dec 2003   Posts: 5  
Post Posted: 2004-01-18 19:17
Back to top  Reply with quote     

The format of the code the samples looks like this
Code:
$fdd["id"]["name"] = "Id";
$fdd["id"]["sort"] = true;
$fdd["id"]["select"] = "T";
$fdd["last_name"]["name"] = "Last Name";
$fdd["last_name"]["sort"] = true;
$fdd["last_name"]["select"] = "T";


the code generated on my forms looks like this
Code:

$opts['fdd']['serialNumber'] = array(
  'name'     => 'SerialNumber',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'nowrap' => true,
  'sort'     => true
);
$opts['fdd']['pedidonum'] = array(
  'name'     => 'Pedidonum',
  'options'   => 'ACPDV',
  'select'   => 'T',
  'maxlen'   => 22,
  'sort'     => true


I'd like to add some drop down lookups to certain fields and so forth. I feel like I understand the concepts. I see what is going on in the sample code. I paste and change the sample code. I do not succeed. My forms code and the sample code are so diferent in format, that I can not figure out what to do...

Any thoughts.

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-01-18 20:33
Back to top  Reply with quote     

http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.fields.html#AEN551

look for "two" ways of array definition

 
jpgus     Joined: 04 Dec 2003   Posts: 5  
Post Posted: 2004-01-18 23:38
Back to top  Reply with quote     

From your link I see two ways.

Type 1) "Direct"
Code:

$opts['fdd']['col_name'] = array('option' => 'value')

Type 2 "Postinitialization"
Code:

$opts['fdd']['col_name']['option'] = 'value' which is used in many examples in this documentation.


This sample appears to be the second type
Code:

$fdd['office']['values']['table'] = 'offices';
   $fdd['office']['values']['column'] = 'office_code';
   $fdd['office']['values']['description'] = 'town';

How would I add that to my phpMyEdit generated form whose output is looks like this.
Code:

$opts['fdd']['Cepillo'] = array(
  'name'     => 'Cepillo',
  'select'   => 'T',
  'maxlen'   => 255,
  'sort'     => true
);


Would I do something like this?
Code:

$opts['fdd']['Cepillo'] = array(
  'name'     => 'Cepillo',
  'select'   => 'D',
  'maxlen'   => 255,
  'sort'     => true
  'values'   => table='tblcepillo'
  'values'   => column='idcepillo'
  'values'   => description='desccepillo'
);


I am sure this is wrong but at least you can see I am trying.... Thanks for the help

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-01-18 23:46
Back to top  Reply with quote     

either
Code:

$opts['fdd']['colname'] = array (
   'name' => 'Name',
   ...
   'values => array (
      'column' => 'id',
      ...
      ),
   ...
   );

or
Code:

$opts['fdd']['colname'] = array (
   'name' => 'Name',
   ...
   );
$opts['fdd']['colname']['values']['column'] = 'id';
...

that does not matter.

once you get used to it, it is easy :)

but i can imagine your problems. could you write a documentation (for this part) which would be understandable to beginners ? as you can imagine, explaining 'obvious' things is really hard.

 
jpgus     Joined: 04 Dec 2003   Posts: 5  
Post Posted: 2004-01-22 00:58
Back to top  Reply with quote     

Please check my response for accuracy. I hope it is helpful to someone. You were quite helpful to me so I am glad I could contribute a bit.

michal wrote:
but i can imagine your problems. could you write a documentation (for this part) which would be understandable to beginners ? as you can imagine, explaining 'obvious' things is really hard.


Though, I am not confident I understand... I'll try to document.

There are two formats for expressing arrays. The examples at http://phpmyedit.org/configuring.php follow the "postinitialization" format. The code that is generated by the current version(phpMyEdit-5.3.tar.gz) follows the "direct" format. Do not fear. The two formats can be used interchangebly and even intermixed as shown below.

The two formats.


Type 1) "Direct"
Code:

$opts['fdd']['col_name'] = array('option' => 'value')

Type 2 "Postinitialization"
Code:

$opts['fdd']['col_name']['option'] = 'value'



Code samples in the documentation.

Code:
$fdd["id"]["name"] = "Id";
$fdd["id"]["sort"] = true;
$fdd["id"]["select"] = "T";
$fdd["last_name"]["name"] = "Last Name";
$fdd["last_name"]["sort"] = true;
$fdd["last_name"]["select"] = "T";


Code generated on my forms
Code:

$opts['fdd']['serialNumber'] = array(
  'name'     => 'SerialNumber',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'nowrap' => true,
  'sort'     => true
);
$opts['fdd']['pedidonum'] = array(
  'name'     => 'Pedidonum',
  'options'   => 'ACPDV',
  'select'   => 'T',
  'maxlen'   => 22,
  'sort'     => true


One can use either or both.... when adding an array of values for drop down selection.

"DIRECT"
Code:

$opts['fdd']['serialNumber'] = array(
  'name'     => 'SerialNumber',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'nowrap' => true,
  'sort'     => true
  'values => array (
   'column' => 'serialnumid',
   'table'   => 'tblserialnum'
        'desription => 'serialnumdescip'
      ),
   );


Combined "DIRECT" with drop down using "POSTINITIALIZATION"
Code:

$opts['fdd']['serialNumber'] = array(
  'name'     => 'SerialNumber',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'nowrap' => true,
  'sort'     => true
);
$fdd["Serialnumber"]["values"]["table"] = "tblserialnum";
$fdd["Serialnumber"]["values"]["column"] = "serialnumid";
$fdd["Serialnumber"]["values"]["description"]
= 'serialnumdescrip';




Both ways work. Just take care to use closing punctuation.

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-01-23 01:24
Back to top  Reply with quote     

your understanding of array declaration is right.

in your sample $fdd should be replaced by $opts['fdd']. i saw this difference only after carefull reading :-). is the written code working ? standard syntax is with $opts['fdd'], this one should be used.

we'll update this part of documentation, thanks for commenting it.

 
jpgus     Joined: 04 Dec 2003   Posts: 5  
Post Posted: 2004-01-23 01:51
Back to top  Reply with quote     

Glad to give back a little, even if it is disproportionate to what I receive....

by the way
I noticed that my last value is given with 'single quotes' instead of "double" ...

michal wrote:
your understanding of array declaration is right.

in your sample $fdd should be replaced by $opts['fdd']. i saw this difference only after carefull reading :-). is the written code working ? standard syntax is with $opts['fdd'], this one should be used.

we'll update this part of documentation, thanks for commenting it.


 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-01-23 02:06
Back to top  Reply with quote     

single quotes vs double: again, most of the time it does not matter :-) (except for URL option where you have to use single in order to use variables like $value).

i prefer single quotes.

 
nepto     Joined: 06 Jan 2003   Posts: 320   Location: Phoenix, Arizona (USA)
Post Posted: 2004-01-28 21:59
Back to top  Reply with quote     

Concerning to configuration.php - it is old and should be updated. We are currently talking about new website in the "Features" forum.

Concerning to apostrophes vs. quotes. I prefer apostrophes, because they can make PHP to parse code a slightly faster, since in the apostrophes, there is everything as-is, no variables, special characters, etc.

_________________
Ondrej Jombik (Nepto)
Visit my homepage , review my recent CV or projects and give me some feedback .
 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy