dregduc63699 2012-02-29 11:28
浏览 29

Cake Php,获取数据库访问权限和供应商文件夹中的“配置”方法

How to get database acess inside files in vendors folder(app/vendors) in Cake Php, get mysql connected via database.php (Cake structure) .

How to get Configure method inside vendors folder(app/vendors), when we want to set a constant in core.php by Configure.write method .

I created a file 'testvideo.php' inside vendors folder (app/vendors/ZendGdata/library/testvideo.php)

I want to get acess of my databse from this file and Configure method.

  • 写回答

1条回答 默认 最新

  • douwei3172 2012-03-01 22:52
    关注

    I would reconsider your design if you need to access the database from your vendors folder. But in any case, you could do the following:

    require_once('config/database.php');
    $dbConfig = new DATABASE_CONFIG();
    $dblink = mysqli_connect($dbConfig->default['host'], $dbConfig->default['login'], $dbConfig->default['password'], $dbConfig->default['database']);
    

    I would pass the configuration variables to your vendor object instead of reading the configuration from the vendor side. ie:

    App::import('Vendor', 'facebook', array('file' => 'facebook/facebook.php'));
        $facebook = new Facebook(array(
          'appId'  => Configure::read("FB_APP_ID"),
          'secret' => Configure::read("FB_APP_SECRET"),
        ));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数