Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Code Samples vs Generated code

phpMyEdit General     Code Samples vs Generated code
Odoslať novú tému   Odpovedať na tému    
 
jpgus     Založený: 04.12.2003   Príspevky: 5  
Príspevok Zaslal: 2004-01-18 19:17
Návrat hore  Odpovedať s citátom     

The format of the code the samples looks like this
Kód:
$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
Kód:

$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     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2004-01-18 20:33
Návrat hore  Odpovedať s citátom     

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

look for "two" ways of array definition

 
jpgus     Založený: 04.12.2003   Príspevky: 5  
Príspevok Zaslal: 2004-01-18 23:38
Návrat hore  Odpovedať s citátom     

From your link I see two ways.

Type 1) "Direct"
Kód:

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

Type 2 "Postinitialization"
Kód:

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


This sample appears to be the second type
Kód:

$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.
Kód:

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


Would I do something like this?
Kód:

$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     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2004-01-18 23:46
Návrat hore  Odpovedať s citátom     

either
Kód:

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

or
Kód:

$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     Založený: 04.12.2003   Príspevky: 5  
Príspevok Zaslal: 2004-01-22 00:58
Návrat hore  Odpovedať s citátom     

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 Napísal:
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"
Kód:

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

Type 2 "Postinitialization"
Kód:

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



Code samples in the documentation.

Kód:
$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
Kód:

$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"
Kód:

$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"
Kód:

$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     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2004-01-23 01:24
Návrat hore  Odpovedať s citátom     

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     Založený: 04.12.2003   Príspevky: 5  
Príspevok Zaslal: 2004-01-23 01:51
Návrat hore  Odpovedať s citátom     

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 Napísal:
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     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2004-01-23 02:06
Návrat hore  Odpovedať s citátom     

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     Založený: 06.01.2003   Príspevky: 320   Bydlisko: Phoenix, Arizona (USA)
Príspevok Zaslal: 2004-01-28 21:59
Návrat hore  Odpovedať s citátom     

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 .
 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov