douxin9135 2012-04-12 20:37
浏览 26
已采纳

使用Php端阻止EASY APNS

Sorry because I'm pretty bad in PHP

Thus I find myself very very stupidly blocked because I am unable to understand or I have to put my info to my connections in my database file "class_DbConnect.php"

in case the file looks like this:

https://github.com/manifestinteractive/easyapns/blob/master/src/php/classes/class_DbConnect.php ...

So I tried to resolve it myself by watching the video of "demo" but it is obsolette. The php file taken from the demo being different, at least different enough to trouble me!

I am sure it is simple : I have 4 informations (host, username, pass and DB name) but i don't know where to set them in the file ... i know it's in this file but don't know where.

For the rest, we will see later. I have created the necessary DB, I must also understand how the certificates, how to recover, etc. ... but for now, I should like already done with the php part ...

I will post the different findings and actions here ... I'm pretty sure it will be usefull for others.

  • 写回答

2条回答 默认 最新

  • dongxing9219 2012-04-12 20:48
    关注

    you are not to put the information in the file but add them when you declare the class

    Explanation

    The Class Contains

    /**
    * Constructor. Initializes a database connection and selects our database.
    * @param string $host       The host to wchich to connect.
    * @param string $username   The name of the user used to login to the database.
    * @param string $password   The password of the user to login to the database.
    * @param string $database   The name of the database to which to connect.
    */
    function __construct($host, $username, $password, $database)
    {
        $this->DB_HOST     = $host;
        $this->DB_USERNAME = $username;
        $this->DB_PASSWORD = $password;
        $this->DB_DATABASE = $database;
    }
    

    what you need in your PHP code is something like this

    $db = new DbConnect("localhost","username","password","database");
    

    It is a bad practice trying to hard-code values directly in a class what if you need to connect to multiple host or database

    Joe Burnett

    As a beginner you don't need such classes when MySQL as fantastic `mysqli' extension which is also object oriented and very fast .

    The usage is similar to what you have not but does not require any additional including any class

    Example

    $db = new mysqli("localhost","username","password","database");
    

    Fore more information and examples see http://www.php.net/manual/en/mysqli.construct.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在不同的执行界面调用同一个页面
  • ¥20 基于51单片机的数字频率计
  • ¥50 M3T长焦相机如何标定以及正射影像拼接问题
  • ¥15 keepalived的虚拟VIP地址 ping -s 发包测试,只能通过1472字节以下的数据包(相关搜索:静态路由)
  • ¥20 关于#stm32#的问题:STM32串口发送问题,偶校验(even),发送5A 41 FB 20.烧录程序后发现串口助手读到的是5A 41 7B A0
  • ¥15 C++map释放不掉
  • ¥15 Mabatis查询数据
  • ¥15 想知道lingo目标函数中求和公式上标是变量情况如何求解
  • ¥15 关于E22-400T22S的LORA模块的通信问题
  • ¥15 求用二阶有源低通滤波将3khz方波转为正弦波的电路