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  »  Field automatically calculates and stores to DB

phpMyEdit General     Field automatically calculates and stores to DB
Odoslať novú tému   Odpovedať na tému    
 
JackAC     Založený: 31.07.2012   Príspevky: 1  
Príspevok Zaslal: 2012-07-31 13:49
Návrat hore  Odpovedať s citátom     

I'm trying to design a proof-of-concept system for our company to save quote files. I am by no means an expert when it comes to PHP or MySQL; more of an enthusiast.

I want to have a field that calculates an element of the quote and stores it to the database automatically to reduce the amount of work the staff member needs to do.

I've got a dummy field with the formula working, but it doesn't store to the database. I don't know what to do to make it. This is what I have:

Kód:

$opts['fdd']['PV_Quote_KwHrs'] = array(
  'name'     => '<b>Kilowatt Hours</b>',
  'select'   => 'T',
  'maxlen'   => 100,
  'number_format' => array(2, '.', ','),
  'options'  => V,
  'sql'      => '(Area / 100 * PV_Survey_Roof_Orientation * PV_Quote_KwPP)',
  'sort'     => true
);


Any suggestions? I hope I'm being clear enough - any help would be really appreciated.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2012-07-31 16:29
Návrat hore  Odpovedať s citátom     

I can't visualize the immediate solution.

Probably it would include a trigger upon Insert and/or Update actions.
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.triggers.html

I'm not sure if upon Insert/Change the $newvals includes values for dummy fields. For debugging, you might add to your trigger file:
Kód:
ksort($newvals);
$print_r_text = preg_replace('/\n/s', "\r\n", print_r($newvals, true));
echo !stristr($print_r_text, ']') ? '' : "\n".'<p>$newvals</p><pre>'.htmlspecialchars($print_r_text).'</pre>';


Reference:
Kód:
Variables available within included triggers:

$this             object reference

$this->dbh        initialized MySQL database handle

$this->key        primary key name

$this->key_type   primary key type

$this->key_delim  primary key deliminator

$this->rec        primary key value (update and delete only)

$newvals          associative array of new values (update and insert only)

$oldvals          associative array of old values (update and delete only)

$changed          array of keys with changed values


Triggers cheat sheet: http://www.php-form-generator.com/phpmyedit/cheat-sheet/triggers.txt

 
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