Hi there,
I have a php codon module that read a condition and write to the database, but I guess I miss something, as it does not write to the database.
First question: how can I see if it actually read the data (create a log or something)
Secondly is there something missing in this code, that prevent from writing to the database?
here is the code:
[php]<?php
/**
- phpVMS - Virtual Airline Administration Software
- Copyright © 2008 Nabeel Shahzad
- For more information, visit www.phpvms.net
- Forums: http://www.phpvms.net/forum
- Documentation: http://www.phpvms.net/docs
- phpVMS is licenced under the following license:
- Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
- View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
class Aircraft_Condition extends CodonModule
{
public function __index()
{
CodonEvent::addListener(‘Aircraft_Condition’);
}
public function EventListener($eventinfo)
{
if($eventinfo[0] == 'pirep_filed')
$pirepinfo = $eventinfo[2];
//Retrieve the aircraft info based on the aircraft id stored in the pirep row
$aircraft = OperationsData::getAircraftByReg($pirepinfo->registration);
//Figure out the $cond that needs to be placed into the
if($pirepinfo->landingrate > -100 && $pirepinfo->landingrate <-500)
$cond = $aircraft->cond -20;
//update the 'cond' column using the aircraft id for row identification
$update = OperationsData::editAircraft(array('id'=>$pirepinfo->aircraftid, 'cond'=>$cond));
}
}[/php]