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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据