Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Adding arbitrary fields not in DB

phpMyEdit General     Adding arbitrary fields not in DB
Post new topic   Reply to topic    
 
plemieux     Joined: 11 May 2005   Posts: 20  
Post Posted: 2005-09-07 19:10
Back to top  Reply with quote     

Is it possible to add arbitrary field troughout the form that are not part of the database?

What I would like to do is add a checkbox or yes/no select as a flag to apply special triggers. For example, this would allow me to delete uploaded files.

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2005-09-08 09:45
Back to top  Reply with quote     

yes,
just create a normal 'column' in pme config, giving it 'AC' flags and create a trigger insert before which will delete $newvals['column'] (cvs version needed)

 
plemieux     Joined: 11 May 2005   Posts: 20  
Post Posted: 2005-09-08 13:35
Back to top  Reply with quote     

My field is set this way:

Code:
$opts['fdd']['delete'] = array(
  'name'     => 'Delete?',
  'select'   => 'T',
  'options'  => 'AC',
  'maxlen'   => 1,
  'sort'     => false
);


and I have put this code in my insert before trigger:

Code:
unset($newvals['delete']);


But that doesn't work. What am I doing wrong?

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2005-09-08 14:29
Back to top  Reply with quote     

you need cvs version of pme

not working means mysql gives error ? or compile error ?

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-09-08 14:42
Back to top  Reply with quote     

Question...the CVS version of PME has a 'virtual' field type (['input'] = 'V'). Would this do the job as from what I can see it doesn't get written to the database as it's not a real field. It's not documented anywhere, so I wondered if it actually worked.

If it did, then you could define a virtual field, I think that you do need to define an 'sql' option for it, but that could be very basic (such as ' ').

 
plemieux     Joined: 11 May 2005   Posts: 20  
Post Posted: 2005-09-08 14:53
Back to top  Reply with quote     

I use the CVS version (1.167).

The error come on the list page clearly because PME try to lookup the field in the DB. Error message is:

Code:
MySQL error 1054
Unknown column 'PMEtable0.delete' in 'field list'


If a virtual field (V) is the way to go, can you provide sample code.

 
plemieux     Joined: 11 May 2005   Posts: 20  
Post Posted: 2005-09-08 18:41
Back to top  Reply with quote     

Setting the field to virtual V with an empty SQL doesn't work.

Code:
$opts['fdd']['delete'] = array(
  'name'     => 'Delete?',
  'select'   => 'V',
  'options'  => 'AC',
  'maxlen'   => 1,
  'sort'     => false,
  'sql'      => ''
);


It return an SQL syntax error.

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-09-09 08:02
Back to top  Reply with quote     

Firstly it's the 'display' option that needs to be set to 'V'. For the 'sql' option, I suggest that you set it to something like '1'

 
pvargas     Joined: 03 Oct 2005   Posts: 1  
Post Posted: 2005-10-03 15:23
Back to top  Reply with quote     

plemieux wrote:
Setting the field to virtual V with an empty SQL doesn't work.

Code:
$opts['fdd']['delete'] = array(
  'name'     => 'Delete?',
  'select'   => 'V',
  'options'  => 'AC',
  'maxlen'   => 1,
  'sort'     => false,
  'sql'      => ''
);


It return an SQL syntax error.


you can test this

$opts['fdd']['virtual_01'] = array(
'name' => ' ',
'select' => 'V',
'options' => 'L', // Only list
'maxlen' => 1,
'sort' => false,
'sql' => 'now()',
'display' => 'V',
'URLdisp' => "Text",
'URL' => 'link_to.php?ID=$key',
'URLtarget'=> '_self',
)

 
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