-2

我想在我的“Adaptive_paypal_model”中扩展 Paypal_class_model。当我写

   class Adaptive_paypal_model extends Paypal_class_model
   {

此代码显示错误消息:

 Fatal error: Class 'Paypal_class_model' not found in C:\xampp\htdocs\business1\application\models\adaptive_paypal_model.php on line 3

请帮我

这是我要包含的代码。请告诉我在 php 中包含文件的另一种方法

         class Paypal_class_model extends CI_Model
      {


     function Paypal_class_model()
         {

 $APIUsername = '';
 $APIPassword = '';
 $APISignature = '';
 $APISubject = '';
 $APIVersion = '';
$APIButtonSource = '';
 $APIMode = '';
 $EndPointURL = '';
        $Sandbox = '';
 $BetaSandbox = '';
 $PathToCertKeyPEM = '';
 $SSL = '';


function __construct($DataArray)
{       
    if(isset($DataArray['Sandbox']))
    {
        $this->Sandbox = $DataArray['Sandbox'];

    }
    elseif(isset($DataArray['BetaSandbox']))
    {
        $this->Sandbox = $DataArray['BetaSandbox'];
    }
    else
    {
        $this->Sandbox = true;
    }

    $this->Sandbox = isset($DataArray['Sandbox']) || isset($DataArray['BetaSandbox']) ? $DataArray['Sandbox'] : true;
    $this->BetaSandbox = isset($DataArray['BetaSandbox']) ? $DataArray['BetaSandbox'] : false;
    $this->APIVersion = isset($DataArray['APIVersion']) ? $DataArray['APIVersion'] : '95.0';
    $this->APIMode = isset($DataArray['APIMode']) ? $DataArray['APIMode'] : 'Signature';
    $this->APIButtonSource = 'AngellEYE_PHPClass';
    $this->PathToCertKeyPEM = '/path/to/cert/pem.txt';
    $this->SSL = $_SERVER['SERVER_PORT'] == '443' ? true : false;
    $this->APISubject = isset($DataArray['APISubject']) ? $DataArray['APISubject'] : '';

    if($this->Sandbox || $this->BetaSandbox)
    {
        // Show Errors
        error_reporting(E_ALL);
        ini_set('display_errors', '1');

        if($this->BetaSandbox)
        {
            # Beta Sandbox
            $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : '';
            $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : '';
            $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : '';
            $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://api-3t.beta-sandbox.paypal.com/nvp';    
        }
        else
        {
            # Sandbox
            $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : '';
            $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : '';
            $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : '';
            $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != '' ? $DataArray['EndPointURL'] : 'https://api-3t.sandbox.paypal.com/nvp'; 
        }
    }
    else
    {
        $this->APIUsername = isset($DataArray['APIUsername']) && $DataArray['APIUsername'] != '' ? $DataArray['APIUsername'] : '';
        $this->APIPassword = isset($DataArray['APIPassword']) && $DataArray['APIPassword'] != '' ? $DataArray['APIPassword'] : '';
        $this->APISignature = isset($DataArray['APISignature']) && $DataArray['APISignature'] != '' ? $DataArray['APISignature'] : '';
        $this->EndPointURL = isset($DataArray['EndPointURL']) && $DataArray['EndPointURL'] != ''  ? $DataArray['EndPointURL'] : 'https://api-3t.paypal.com/nvp';
    }

    // Create the NVP credentials string which is required in all calls.
    $this->NVPCredentials = 'USER=' . $this->APIUsername . '&PWD=' . $this->APIPassword . '&VERSION=' . $this->APIVersion . '&BUTTONSOURCE=' . $this->APIButtonSource;
    $this->NVPCredentials .= $this->APISubject != '' ? '&SUBJECT=' . $this->APISubject : '';
    $this->NVPCredentials .= $this->APIMode == 'Signature' ? '&SIGNATURE=' . $this->APISignature : '';




} ?>
4

1 回答 1

0

您可以只自动加载模型,但可以在此处找到更好的解决方案:在 Codeigniter 2 中扩展多个模型 您可以节省每次调用中自动加载的开销。

于 2012-12-21T09:10:11.897 回答