Gossamer Forum
Home : General : Internet Technologies :

PHP 4.3.9 after upgrade problems!

Quote Reply
PHP 4.3.9 after upgrade problems!
Hi! We just upgraged to PHP 4.3.9 and experience some code functionality problems. Which does not make any sense.
Fatal error: Call to undefined function: onselect()
Does anybody experienced something like that and what could cause something this problem?

This is how the function looks like
============================================================
function select()
{
$this->onSelect();
$objDB = createDataBase();
$sOrderBy = getValue("order_by", $GLOBALS["Variables"]);
if ($sOrderBy != "")
{
$vtrFieldArray = getValue($sOrderBy, $this->m_vtrFields);
if (gettype($vtrFieldArray) == 'array')
{
$sOrderBy = " order by ".($vtrFieldArray[1])." asc";
}
else
{
$sOrderBy = "";
}
}
$sRequest = "select ";
for ($nCount = 0; $nCount < count($this->m_vtrFields); ++$nCount)
{
if ($nCount != 0)
{
$sRequest .= " , ";
}
$sRequest .= $this->m_vtrFields[$nCount][1];
}
$sRequest .= " from ";
for ($nCount = 0; $nCount < count($this->m_vtrTables); ++$nCount)
{
if ($nCount != 0)
{
$sRequest .= " , ";
}
$sRequest .= $this->m_vtrTables[$nCount];
}
if (($this->m_nID != "") || ($this->m_sWhereClause != ""))
{
$sRequest .= " where ";
}
if ($this->m_nID != "")
{
$sRequest .= " ".$this->m_vtrTables[0].".id=".$this->m_nID;
if ($this->m_sWhereClause != "")
{
$sRequest .= " and ";
}
}

if ($this->m_sGroupClause != "")
{
$sRequest .= $this->m_sGroupClause;
}

$sRequest .= $this->m_sWhereClause;
$sRequest .= $sOrderBy;


$this->m_vtrResultTable = $objDB->execute($sRequest);
}
==========================================================
Thank a lot
Quote Reply
Re: [doom] PHP 4.3.9 after upgrade problems! In reply to
Possibly because select() is a reserved function in PHP? Try renaming it _select, or custom_select ... so that it differs from normal functions.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] PHP 4.3.9 after upgrade problems! In reply to
No. I don't think there is any reserved select() function in php.

Thanks
Quote Reply
Re: [doom] PHP 4.3.9 after upgrade problems! In reply to
I did some investigations there is some magic there.
Example:
I already have function, let's say
function A1();


in another function:
function funcCall()
{
$this->A1();
//Call to the function A1()
}


This works fine, but if I create any other function (even with empty body) and will call it instead of A1 I will get this error. Locally it works fine and I haven't changed this staff before and after the PHP move.
Quote Reply
Re: [doom] PHP 4.3.9 after upgrade problems! In reply to
The error relates to onselect function call within select function, and not select function per se. Is onselect defined or properly referenced by calling PHP file? Can we see the entire code? If code too large, copy to .txt file on your server and provide link to file.

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] PHP 4.3.9 after upgrade problems! In reply to
Here is the code!
==============================================================
<?php
include_once("services/view.php");
class DBView extends View
{
var $m_nID;
var $m_vtrFields;
var $m_vtrTables;
var $m_sWhereClause;
var $m_sGroupClause;
var $m_vtrResultTable;
var $m_sFileName;
var $m_sForcedAction;
var $m_vtrCleanUp;

function DBView()
{
parent::View();
}

function reset()
{
$this->m_nID = "";
$this->m_vtrResultTable = null;
$this->m_sFileName = "";

for ($nIndex = 0; $nIndex < count($this->m_vtrCleanUp); ++$nIndex)
{
unset($this->m_vtrCleanUp[$nIndex], $GLOBALS["Variables"]);
}
$GLOBALS["System"]->dumpVariables();
$this->m_vtrCleanUp = array();
}

function run()
{
$this->parseID();
$sAction = getValue("action", $GLOBALS["Variables"]);
if ($this->m_sForcedAction != "")
{
$sAction = $this->m_sForcedAction;
}
switch ($sAction)
{
case "delete":
$this->delete();
break;
case "update":
$this->update();
break;
case "save":
$this->save();
break;
case "send":
$this->select();
$this->send();
break;
default:
$this->select();
}
unset($GLOBALS["Variables"]["process_ids"]);
unset($GLOBALS["Variables"]["action"]);
unset($GLOBALS["Variables"]["order_by"]);
unset($GLOBALS["Variables"]["send_template"]);
$this->cleanUpBeforeView();
if (($sAction == 'delete') || ($sAction == 'update'))
{
$this->m_nID = "";
$this->restoreTableHeader();
$this->select();
}
$sResult = parent::run();
$this->reset();
return $sResult;
}

function send()
{
$sEMail = $this->getTag("email");
$objTemplateManager = new TemplateManager();
$objTemplateManager->init($GLOBALS["Config"]);
$objTemplateManager->preloadTemplates();
$sMessage = $objTemplateManager->renderTemplate(getValue("send_template", $GLOBALS["Variables"]), $this);
//$GLOBALS["Logger"]->write("EMail: $sEMail");
//$GLOBALS["Logger"]->write("Message: $sMessage");
if (mail($sEMail, "Automatic message from Solaris system", $sMessage) == TRUE)
{
$GLOBALS["Logger"]->write("E-mail has been sent");
}
else
{
$GLOBALS["Logger"]->write("Errors while sending E-mail");
}
}

function delete()
{
if ($this->m_nID != "")
{
$objDB = createDataBase();
$objDB->execute("delete from ".($this->m_vtrTables[0])." where id=".$this->m_nID);
}
}

function update()
{
$objDB = createDataBase();
if ($this->m_nID == "")
{
$this->m_vtrResultTable = $objDB->execute("select max(id) from ".$this->m_vtrTables[0]);
$this->m_nID = $this->m_vtrResultTable[0][0];
$this->m_nID++;
}

$objReplace = new ReplaceQuery($this->m_vtrTables[0]);
for ($nCount = 0; $nCount < count($this->m_vtrFields); ++$nCount)
{
if ($this->m_vtrFields[$nCount][2] == 0)
{
$objReplace->addNumericValue($this->m_vtrFields[$nCount][1], getValue($this->m_vtrFields[$nCount][0], $GLOBALS["Variables"], 0));
}
if ($this->m_vtrFields[$nCount][2] == 1)
{
$objReplace->addQuotedValue($this->m_vtrFields[$nCount][1], getValue($this->m_vtrFields[$nCount][0], $GLOBALS["Variables"]));
}
unset($GLOBALS["Variables"][$this->m_vtrFields[$nCount][0]]);
}
$objReplace->addNumericValue("id", $this->m_nID);

$this->onUpdate($objReplace);

$objDB->execute($objReplace->getQuery());
}

function cleanUpBeforeView()
{
//should be implemented in derived classes
}
function onUpdate(&$objReplace)
{
//any additional field updates can be added here
}

function onSelect()
{
//any additional field updates can be added here
}
function restoreTableHeader()
{
//should be implemented in derived classes
}
function select()
{
$this->onSelect();
$objDB = createDataBase();
$sOrderBy = getValue("order_by", $GLOBALS["Variables"]);
if ($sOrderBy != "")
{
$vtrFieldArray = getValue($sOrderBy, $this->m_vtrFields);
if (gettype($vtrFieldArray) == 'array')
{
$sOrderBy = " order by ".($vtrFieldArray[1])." asc";
}
else
{
$sOrderBy = "";
}
}
$sRequest = "select ";
for ($nCount = 0; $nCount < count($this->m_vtrFields); ++$nCount)
{
if ($nCount != 0)
{
$sRequest .= " , ";
}
$sRequest .= $this->m_vtrFields[$nCount][1];
}
$sRequest .= " from ";
for ($nCount = 0; $nCount < count($this->m_vtrTables); ++$nCount)
{
if ($nCount != 0)
{
$sRequest .= " , ";
}
$sRequest .= $this->m_vtrTables[$nCount];
}
if (($this->m_nID != "") || ($this->m_sWhereClause != ""))
{
$sRequest .= " where ";
}
if ($this->m_nID != "")
{
$sRequest .= " ".$this->m_vtrTables[0].".id=".$this->m_nID;
if ($this->m_sWhereClause != "")
{
$sRequest .= " and ";
}
}

if ($this->m_sGroupClause != "")
{
$sRequest .= $this->m_sGroupClause;
}

$sRequest .= $this->m_sWhereClause;
$sRequest .= $sOrderBy;


$this->m_vtrResultTable = $objDB->execute($sRequest);
}
function save()
{
$this->select();
$this->m_sFileName = getValue("temp", $GLOBALS["Variables"])."/save_file_".time().".csv";
$fp = fopen($this->m_sFileName, "w+");
for ($nCount = -1; $nCount < count($this->m_vtrResultTable); ++$nCount)
{
$bWasOutputted = false;
for ($nFieldCount = 0; $nFieldCount < count($this->m_vtrResultTable[0]); ++$nFieldCount)
{
if ($this->m_vtrFields[$nFieldCount][3] == "")
{
continue;
}
if ($bWasOutputted == true)
{
fputs($fp, ", ");
}
$bWasOutputted = true;
if ($nCount == -1)
{
fputs($fp, $this->m_vtrFields[$nFieldCount][3]);
}
else
{
fputs($fp, $this->m_vtrResultTable[$nCount][$nFieldCount]);
}
}
fputs($fp, "\n");
}
fclose($fp);
}

function parseID()
{
$vtrIDs = explode(",", getValue("process_ids", $GLOBALS["Variables"]));
$this->m_nID = trim($vtrIDs[0], "a..z ");
}

function getTag($sTagName)
{
if (count($this->m_vtrResultTable) == 0)
{
return "";
}
$sResult = "";
if (strpos($sTagName, "##") !== FALSE)
{
list($nRow, $nCol) = explode("##", $sTagName, 2);
$sResult = $this->m_vtrResultTable[$nRow][$nCol];
}
else if ($sTagName == "FileLink")
{
$sResult = $this->m_sFileName;
}
else if ($sTagName == "RowTotal")
{
$sResult = $this->getRowCount();
}
else
{
for ($nCount = 0; $nCount < count($this->m_vtrFields); ++$nCount)
{
if ($this->m_vtrFields[$nCount][0] == $sTagName)
{
$sResult = $this->m_vtrResultTable[0][$nCount];
}
}
}
return $sResult;
}

function getRowCount()
{
return count($this->m_vtrResultTable);
}
function addWhereClause(&$sAdditionalVar, $sFieldName, $sName, $bPushToCleanUp = false, $bQuoted = false, $sOperation = "=", $bInsertAfter = true)
{
$sValue = getValue($sName, $GLOBALS["Variables"]);
if ($sValue == "")
{
return false;
}
$sCondition = " $sFieldName $sOperation ".(($bQuoted == true)?("'$sValue'"):($sValue));
if ($bInsertAfter)
{
$this->m_sWhereClause .= " and $sCondition ";
$sAdditionalVar .= " and $sCondition ";
}
else
{
$this->m_sWhereClause = " $sCondition and " .$this->m_sWhereClause;
$sAdditionalVar = " $sCondition and " .$sAdditionalVar;
}
if ($bPushToCleanUp)
{
$this->m_vtrCleanUp[] = $sName;
}
return true;
}

}
Quote Reply
Re: [doom] PHP 4.3.9 after upgrade problems! In reply to
Hi!

Just want to let everybody know that i found the source of the problem in php.ini configuration. Exactly PHP Accelerator was causing the problem.
So i turn it off
;zend_extension="/lib/phpa/php_accelerator_1.3.3r2.so
works now.
Any idea why?


Cheers.