php - 在codeiginter中读取配置文件中的数据库
问题描述
我正在通过此链接https://www.codexworld.com/paypal-payment-gateway-integration-in-codeigniter/集成贝宝。一切正常,完全没有问题。但我必须在 paypal 的配置文件中写入 paypal 的帐户电子邮件。我想给管理员选择,以便他可以更改贝宝帐户。我试图访问 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';
我怎么能做到这一点。任何形式的帮助将不胜感激
解决方案
$this
在控制器中工作以访问方法。我们不能$this
在控制器类之外使用。所以使用
$CI =& get_instance();
$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
// etc.
有用。有关更多详细信息,请访问user_guide
推荐阅读
- logging - 如何扫描我的网络以查找作为域控制器运行的机器?
- android - python中的getchar返回权限被拒绝(andorid 8.0)
- android - 将位图设置为背景并裁剪
- java - 在 Java 中进行不自动增量的批量插入
- javascript - html2pdf 库返回空白字段
- java - 如何在使用 Plexus Archiver 和 Apache Maven 制作的 java 项目中编辑一些硬编码密钥
- jdbc - Confluent:加载连接器后未创建主题
- visual-studio-2017 - ilmerge.internalize.exclude.txt 文件有什么作用?
- postgresql - Postgresql 使用 where 子句选择视图太慢
- arrays - PHP - 函数前的方括号