2010-08-09 26 views
0

行,所以我有一個PHP文件,該文件包含的代碼做一個SQL INSERTPHP類讓我訪問所需的變量

myfile.php

include($somewhere.'/addleads.php'); 

addleads.php

require_once(MAIN_CLASS_PATH."common/class.Common.php"); 
require_once(MAIN_CLASS_PATH."modules/Leads/class.Leads.php"); 
$objcommon = new common(); 
$objLeads  = new Leads(); 
$Errormsg = $objLeads->AddLBCleads($_REQUEST); 

class.Leads.php

class Leads extends Common{ 

function Leads(){ 
    $this->Common(); 
    $this->Leadstype  = "Leadstype"; 
    $this->Leads   = "Leads"; 


} 

function AddLBCleads($objArray){ 

    global $_REQUEST,$objSmarty,$global_config; 
    $objLeads = new Leads(); 
    $objInsertArray['txtP_Ident']  = $objArray['selProperty']; 
    $objInsertArray['txtFirstName']  = $objArray['txtfirstname']; 
    $objInsertArray['txtLastName']  = $objArray['txtlastname']; 
    $objInsertArray['txtEmail']   = $objArray['txtEmail']; 
    $objInsertArray['txtPhone']   = $objArray['txtPhone']; 
    $objInsertArray['txtTypeId']  = $objArray['selleadtype']; 
    $objInsertArray['txtComments']  = $objArray['txtcomments']; 
    $StrEnterdate      = date('Y-m-d H:i:s'); 
    $objInsertArray['txtMoveDate']  = $StrMoveDate; 
    $objInsertArray['txtEntereddate'] = $StrEnterdate; 

    $current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads); 

我如何得到myfile.php $ current_id,當我試圖訪問它不可用

回答

2

略低於該行:

class Leads extends Common{ 

地址:

public $current_id = null; // create a public accessible variable 

,而不是和:

$current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads); 

用途:

$this->current_id = $this->AddInfoToDB($objInsertArray,"txt",$this->LBCPrimary_leads); 

現在,你可以把它想:

$objLeads = new Leads(); 
echo $objLeads->current_id;