Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by LeitrimMan on Dec 11, 2009 04:38
open dhtmlx forum
get_value of aliased column

Hi, I cannot get the value of an aliased column using get_value.. not sure what I'm doing wrong, here is the SQL

$GetCalloutsSQL = "select t1.CalloutID, t1.ClientID, t1.JobID, t3.CalloutName as JobCalloutName, t2.TaskDesc, t1.NumberCrew, t1.CalloutDate, t1.ChargeRate, t1.StartTime, t1.NumberHours, t4.lookuptext as COStatus, t1.Location, t5.ContactName from callouts t1, tasks t2, callouttypes t3, lookups t4, contacts t5 where t1.TaskID=t2.TaskID and t1.CallOutTypeID = t3.CalloutTypeID and t1.Status=t4.lookupvalue and t4.lookupkey='calloutstatus' and t1.JobID=$_GET[JobID] and t1.ContactID=t5.ContactID order by CalloutDate, StartTime, TaskDesc asc";


and the render

$resconn->render_sql($GetCalloutsSQL,"CalloutID", "NumberCrew,TaskDesc,t3.CalloutName(JobCalloutName),CalloutDate,StartTime,NumberHours,ChargeRate,Location,ContactName,t4.lookuptext(COStatus)");


but using

$CalloutType= $action->get_value("JobCalloutName");

returns no value... what is the correct way of getting the value for this aliased column? I have tried various things but none work..
Answer posted by Alex (support) on Dec 11, 2009 05:07

Hello,

the $action->get_value("JobCalloutName"); method is called correctly. You can try to enable log to get details:

$scheduler->enable_log("log.txt",true);

Answer posted by LeitrimMan on Dec 11, 2009 05:23

Hi Alex,

 

I have tried this, and it still does not update, here is the log - (by the way, what does the error undefined offset mean?)


Log started, 11/12/2009 01:12:16
====================================

SELECT  contacts.ContactID, contacts.ContactName FROM contacts, jobs WHERE  jobs.ClientID=contacts.ClientID and Jobs.JobID=946

Undefined offset:  1 at C:\xampp\htdocs\esionline3\codebase\db_common.php line 207

Undefined offset:  1 at C:\xampp\htdocs\esionline3\codebase\db_common.php line 207

DataProcessor object initialized
4748_gr_id => 4748
4748_c0 => 3
4748_c1 => Flyman
4748_c2 => 2
4748_c3 => 2009-11-16
4748_c4 => 14:00
4748_c5 => 5
4748_c6 => 25
4748_c7 => RDS
4748_c8 =>
4748_c9 => Confirmed
4748_!nativeeditor_status => updated
ids => 4748

Row data [4748]
CalloutID => 4748
NumberCrew => 3
TaskDesc => Flyman
JobCalloutName => 2
CalloutDate => 2009-11-16
StartTime => 14:00
NumberHours => 5
ChargeRate => 25
Location => RDS
ContactName =>
COStatus => Confirmed
!nativeeditor_status => updated

Event code for update processed

Edit operation finished
0 => action:updated; sid:4748; tid:4748;

Done in 0.00554704666138s

here is the code to try and update the database from these values...all other fields but  CalloutName='$CalloutType', CallOutTypeID=$CalloutType update...

 

 function custom_update($action)
 {
    $id = $action->get_id();
    $NumCrew = $action->get_value("NumberCrew");
    $CalloutType= $action->get_value("JobCalloutName");
    $TaskID = $action->get_value("TaskDesc");
    $CalloutDate = $action->get_value("CalloutDate");
    $StartTime = $action->get_value("StartTime");
    $NumberHours = $action->get_value("NumberHours");
    $Location = $action->get_value("Location");
       
     mysql_query("update callouts SET NumberCrew=$NumCrew, TaskID=$TaskID, StartTime='$StartTime', CalloutName='$CalloutType', CallOutTypeID=$CalloutType, CalloutDate='$CalloutDate',  Location='$Location', NumberHours=$NumberHours WHERE CalloutID=$id");
     
    $action->success();
 }

Answer posted by LeitrimMan on Dec 11, 2009 05:51

Hi Alex,

 

yes - heres table structure

CREATE TABLE IF NOT EXISTS `callouts` (
  `CalloutID` int(11) NOT NULL AUTO_INCREMENT,
  `ClientID` int(11) NOT NULL,
  `JobID` int(11) NOT NULL,
  `CallOutTypeID` int(30) NOT NULL,
  `CalloutName` varchar(50) NOT NULL,
  `NumberCrew` int(11) NOT NULL,
  `CalloutDate` date NOT NULL,
  `StartTime` varchar(5) NOT NULL,
  `FinishTime` time NOT NULL,
  `NumberHours` int(11) NOT NULL,
  `ChargeRate` float NOT NULL,
  `Status` int(2) NOT NULL,
  `TaskID` int(11) NOT NULL,
  `ContactID` int(11) NOT NULL,
  `Location` varchar(30) DEFAULT NULL,
  `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `accCalloutID` int(11) NOT NULL,
  PRIMARY KEY (`CalloutID`),
  KEY `ClientID` (`ClientID`),
  KEY `JobID` (`JobID`),
  KEY `TaskID` (`TaskID`),
  KEY `CalloutDate` (`CalloutDate`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4823 ;

Answer posted by Alex (support) on Dec 11, 2009 05:54

According to the log result the JobCalloutName parameter is passed and contains value 2 - JobCalloutName => 2

So, it seems that everything should be ok.