Jump to content

"Call to member function on a non-object" on and object?!


wesblake

Recommended Posts

Well, I have the following (simplified) classes.
[size=9pt][color=green]<?php
include_once("Wrapper.php");
include_once("Declarations.php");

class ApplicantData extends Wrapper  {

var $fnmFile; // Representation of the Fannie Mae File
var $row; // Row of Data
...

/**
* Place Holder for ApplicantData sub Objects
* @var
*/
                ...
var $declarations; //One Object per Applicant
...

/**
*  This takes a FNM file like loan app,
* breaks apart the other rows like normal
* A lot of the same functionality of loan app
*
* @param unknown_type $fnmFile
* @return ApplicantData
*/
function ApplicantData($fnmFile = '',$row,$rowNumber){
parent::Wrapper($fnmFile);
$this->row = $row;
$this->rowNumber = $rowNumber;
//Call construct methods below
...
$this->constructDeclarations();
...
}
function getLoanAppId(){
return $this->loanAppId;
}
function setLoanAppId($id){
$this->loanAppId = $id;
}

function constructDeclarations(){
$row = $this->getSegmentRow($this->SEGMENT_DECLARATIONS);
$Declaration = new Declarations($row);
if($Declaration->getApplicantSSN() == $this->getApplicantSSN()){
$this->declarations = $Declaration;
}
}

function getDeclarations(){
return $this->declarations;
}

/**
* $check_notify = Bool for ACL checking.
* Saves the currently loaded FannieMae object in database.
*
* @return record result of insert
*/
function save($isUpdate = FALSE) {
$db = & PearDatabase::getInstance();

if($isUpdate){
$query = "DELETE FROM applicant_data WHERE fannieMaeId='". $this->getLoanAppId()."' ";
foreach ($this->assoc_tables as $currTable) {
$query .= "; DELETE FROM $currTable WHERE fannieMaeId='".$this->getLoanAppId()."' and applicantSSN='".$this->getApplicantSSN()."' ";
}
$GLOBALS['log']->info("Delete ApplicantData: ".$query);
$db->query($query, true);
}
$query = "INSERT into ";

if ($db->dbType == "oci8"){
        } else if ($db->dbType == 'mysql') {
    // write out the SQL statement.
      $query .= "applicant_data set fannieMaeId='".$this->getLoanAppId()."',
      applicantSSN='".$this->getApplicantSSN()."', applicantIndicator='".$this->getApplicantIndicator()."',
      applicantFirstName='".$this->getApplicantFirstName()."', applicantLastName='".$this->getApplicantLastName()."',
      applicantMiddleName='".$this->getApplicantMiddleName()."',
      applicantGeneration='".$this->getApplicantGeneration()."', homePhone='".$this->getHomePhone()."',
      age='".$this->getAge()."', yearsSchool='".$this->getYearsSchool()."', maritalStatusCode='".$this->getMaritalStatusCode()."',
      numDependants='".$this->getNumberOfDependants()."', completedJointly='".$this->getCompletedJointly()."',
      crossRefNumber='".$this->getCrossRefNumber()."', dateOfBirth='".$this->getDateOfBirth()."',
      emailAddress='".$this->getEmailAddress()."' ";
     
    $GLOBALS['log']->info("Insert ApplicantData: ".$query);
        $GLOBALS['log']->info("Save ApplicantData: $query");
$result = $db->query($query, true);
        }

        //Subclasses need to save their own records now
        print_r($this->declarations);
        $this->declarations->setLoanAppId($this->loanAppId);  //LINE 687
return $result;
}
}//end of Class
?>[/color][/size]

[size=9pt][color=blue]<?php
class Declarations{

var $row; // Row of Data
var $loanAppId; // Loan App Id

/** Declarations Specific **/
...

function Declarations($row = ''){
$this->row = $row;
}
function getLoanAppId(){
return $this->loanAppId;
}
function setLoanAppId($id){
$this->loanAppId = $id;
}

/**
* $isUpdate = Indicate wether to use an Insert or Update statement.
* Saves the currently loaded __ object in database.
*
* @return result of insert/update
*/
function save($db) {
$query = "INSERT into ";

if ($this->db->dbType == "oci8"){
        } else if ($this->db->dbType == 'mysql') {
    // write out the SQL statement.
      $query .= "applicant_declarations set applicantSSN='$this->applicantSSN',
      anyOutstandingJudgments='$this->anyOutstandingJudgments',
      declaredBKpast7Years='$this->declaredBKpast7Years',
      propForclosed7Years='$this->propForclosed7Years', partyLawSuit='$this->partyLawSuit',
      directlyOrIndirectlyObligatedLoan='$this->directlyOrIndirectlyObligatedLoan',
      presentlyDeliqFedDebt='$this->presentlyDeliqFedDebt',
      obligatedPayAlimonyChildSupport='$this->obligatedPayAlimonyChildSupport',
      downPaymentBorrowed='$this->downPaymentBorrowed',
      comakerEndorserNote='$this->comakerEndorserNote', USCitizen='$this->USCitizen',
      permResidentAlien='$this->permResidentAlien', intendToOccupy='$this->intendToOccupy',
      ownershipInterest='$this->ownershipInterest', whatTypeOfProperty='$this->whatTypeOfProperty',
      howDidYouHoldTitle='$this->howDidYouHoldTitle' ";
     
    $GLOBALS['log']->info("Insert: ".$query);
        $GLOBALS['log']->info("Save: $query");
    return $this->db->query($query, true);
        }
}
}
?>[/color][/size]

The ... are lines taken out that are not relevant to the problem. Anyways, as you can see, I put in the print_r line in ApplicantData object because of the error I was getting, and here's the output:

[size=9pt][color=red]declarations Object ( [row] => 08A555551212NNNNNNNNN01YY101 [id] => [loanAppId] => [applicantSSN] => [anyOutstandingJudgments] => [declaredBKpast7Years] => [propForclosed7Years] => [partyLawSuit] => [directlyOrIndirectlyObligatedLoan] => [presentlyDeliqFedDebt] => [obligatedPayAlimonyChildSupport] => [downPaymentBorrowed] => [comakerEndorserNote] => [USCitizen] => [permResidentAlien] => [intendToOccupy] => [ownershipInterest] => [whatTypeOfProperty] => [howDidYouHoldTitle] => )
Fatal error: Call to a member function on a non-object in /var/www/localhost/htdocs/basebuild/custom/fanniemae/ApplicantData.php on line 687[/color][/size]

Now how in the world is it an object when I print it out and then in the very next line it's no longer an object? Thanks.
Link to comment
Share on other sites

The way you have it coded here :  $this->declarations->setLoanAppId($this->loanAppId);
means that there is setLoadAppId object within the declarations property in which there is not from what I could see. 

here you have: [code]  function constructDeclarations(){
        $row = $this->getSegmentRow($this->SEGMENT_DECLARATIONS);
        $Declaration = new Declarations($row);
            if($Declaration->getApplicantSSN() == $this->getApplicantSSN()){
              $this->declarations = $Declaration;
        }
      }[/code]

This looks like it would make a new instance of the Declarations Object but you don't seem to call that before $this->declarations->setLoanAppId($this->loanAppId);  therefore I think it's not seeing that setLoadAppId is a method of the Declarations class.  Make sense? ???
Link to comment
Share on other sites

I see the method: [code]      function ApplicantData($fnmFile = '',$row,$rowNumber){
        parent::Wrapper($fnmFile);
        $this->row = $row;
        $this->rowNumber = $rowNumber;
        //Call construct methods below
        ...
        $this->constructDeclarations();
        ...
      }[/code]
However, I do not see where you are constructing this.  You have "Call construct methods" however to initalize that the way it is written, you would have to call ApplicantData first.  If you add a function:
[code]function __construct() { $this->declaration = $this->construct Declarations(); }[/code] That should iniatilize the object.  Do you have a __construct method?
Link to comment
Share on other sites

I'm sorry, I keep leaving information out. There is actually an overall object called FannieMae which has a bunch of objects it holds. One of these object is ApplicantData, FannieMae is constructing ApplicantData (there are way to many objects to post). In turn, ApplicantData has a bunch of object it contains, one of which is this Declarations object.
I am trying to get the series to save, so I call the save function of FannieMae which successfully calls save on all of it's other objects (which do not have more objects of their own like ApplicantData does so they are simple sql calls) and then when it gets to ApplicantData's save function, the sql statement for that is also executed, but it fails at this call trying to call save on it's object(s). Does this clarify?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.