提问者:小点点

读取codeiginter中配置文件内的数据库


我正在通过以下链接整合贝宝:https://www.codexworld.com/paypal-payment-gateway-integration-in-codeigniter/。 一切都很好,一点问题都没有。 但我必须写贝宝的帐户电子邮件的配置文件贝宝。 我想给行政的选择,以便他可以改变贝宝帐户。 我试图访问cofing文件中的数据库,但它给出了错误。 paypal的配置文件如下

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

// ------------------------------------------------------------------------
// Paypal library configuration
// ------------------------------------------------------------------------

 // PayPal environment, Sandbox or Live
 $config['sandbox'] = TRUE; // FALSE for live environment
 $paypal = $this->db->where('set_id',1)->get('settings')->row_array();
 // PayPal business email
 $config['business'] = $paypal['paypal_accnt'];

 // What is the default currency?
 $config['paypal_lib_currency_code'] = 'USD';

 // Where is the button located at?
 $config['paypal_lib_button_path'] = 'assets/images/';

 // If (and where) to log ipn response in a file
 $config['paypal_lib_ipn_log'] = TRUE;
 $config['paypal_lib_ipn_log_file'] = BASEPATH . 'logs/paypal_ipn.log';

我怎么才能做到这一点。 任何形式的帮助都将不胜感激


共1个答案

匿名用户

$这在控制器中起作用,以访问方法。 不能在controller类之外使用$this。 如此使用

$CI =& get_instance();

$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
// etc.

它起作用了。 有关更多详细信息,请访问user_guide