[DB_DataObject]insert() ignoring a set value?

Associate
Joined
21 May 2003
Posts
1,365
I'm using PEAR:: dataObjects to insert enquiries into an internal database. There are two web-forms; one is internal on our intranet (for staff to enter phone calls), and the other is on our external website (for the general public).

They both use an identical copy of the dataObjects class which was autogenerated:
Code:
<?php
/**
 * Table Definition for enquiry
 */
require_once 'DB/DataObject.php';

class DataObjects_Enquiry extends DB_DataObject 
{
    ###START_AUTOCODE
    /* the code below is auto generated do not remove the above tag */

    public $__table = 'enquiry';                         // table name
    public $enquiryID;                       // int(10)  not_null primary_key unsigned auto_increment
    public $timestamp;                       // timestamp(19)  not_null unsigned zerofill binary timestamp
    public $firstName;                       // string(30)  
    public $lastName;                        // string(30)  
    public $addressLine1;                    // string(40)  
    public $addressLine2;                    // string(40)  
    public $addressLine3;                    // string(40)  
    public $addressLine4;                    // string(40)  
    public $postcode;                        // string(8)  
    public $homePhone;                       // string(20)  
    public $secondPhone;                     // string(20)  
    public $emailAddress;                    // string(40)  
    public $sourceOfLead;                    // string(40)  not_null
    public $natureOfLead;                    // string(40)  
    public $callBack;                        // datetime(19)  binary
    public $accepted;                        // string(10)  
    public $notes;                           // blob(65535)  blob
    public $addedBy;                         // string(30)  

    /* Static get */
    function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Enquiry',$k,$v); }

    /* the code above is auto generated do not remove the tag below */
    ###END_AUTOCODE
}

The internal web-form works fine, adding all fields to the database.

The website form seems to work as well, but it always ignores the $addedBy property and I can't work out why.

Code-sample for the internal web form:
Code:
<snip>

$enquiry->emailAddress = mysql_escape_string(strip_tags($_POST['emailAddress']));
$enquiry->sourceOfLead = mysql_escape_string(strip_tags($sourceOfLead));
$enquiry->natureOfLead = mysql_escape_string(strip_tags($natureOfLead));
$enquiry->callBack = mysql_escape_string(strip_tags($callBack));
$enquiry->accepted = mysql_escape_string(strip_tags($accepted));
$enquiry->notes = mysql_escape_string(strip_tags($notes));
						
$enquiry->addedBy = $_SESSION['u_username'];
						
$enquiry->insert();
</snip>

Code sample for a test website form:
Code:
$enquiry = new DataObjects_Enquiry;
	
	$enquiry->addedBy = "webClaim";
	
	echo $enquiry->addedBy;
	
	$enquiry->firstName = "Tom";
	$enquiry->lastName = "Hardman";
	
	$enquiry->insert();

I know $enquiry->addedBy is being set because it echos to the page.

but here are the results of the debug:
DataObjects_Enquiry: QUERY: INSERT INTO enquiry (firstName , lastName ) VALUES ('Tom' , 'Hardman' )
DataObjects_Enquiry: query: QUERY DONE IN 0.00501298904419 seconds

It just completely ignores $enquiry->addedBy ?!?!



Any ideas?
 
It's got me completely stumped... all the other fields work fine so the dataObjects install is obviously functioning correctly...

The webserver is running apache2 with PHP 5.1.1

The intranet server is running IIS6 and PHP 5.1.1
 
Back
Top Bottom