用 Php 端阻止 EASY APNS


Block with Php side for EASY APNS

抱歉,因为我在PHP中很糟糕

因此,我

发现自己非常非常愚蠢地被阻止了,因为我无法理解,或者我必须将我的信息放在我的数据库文件"class_DbConnect.php"中的连接中

如果文件如下所示:

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

所以我试图通过观看"演示"的视频来自己解决它,但它是过时的。从演示中获取的 php 文件是不同的,至少不同到足以困扰我!

我确定这很简单:我有 4 个信息(主机、用户名、通行证和数据库名称),但我不知道在文件中的哪个位置设置它们......我知道它在这个文件中,但不知道在哪里。

其余的,我们稍后再见。我已经创建了必要的数据库,我还必须了解如何证书,如何恢复等。但是现在,我应该喜欢已经完成了 php 部分......

我将在这里发布不同的发现和行动......我很确定这对其他人有用。

你不是把信息放在文件中,而是在声明类时添加它们

解释

该类包含

/**
* 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;
}

你在PHP代码中需要的是这样的

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

这是一个尝试直接在类中硬编码值的bad practice,如果您需要连接到多个hostdatabase

乔·伯内特

作为

初学者,当MySQL作为梦幻般的"mysqli"扩展时,您不需要这样的类,这也是面向对象的并且非常快。

用法类似于您没有的,但不需要任何附加功能,包括任何类

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

有关更多信息和示例

,请参见 http://www.php.net/manual/en/mysqli.construct.php
我会

说这是我见过的最长的MySQL连接脚本,但是你来了...

function __construct($host, $username, $password, $database)
    {
        $this->DB_HOST     = "HostName";
        $this->DB_USERNAME = "username";
        $this->DB_PASSWORD = "password";
        $this->DB_DATABASE = "database";
    }

在代码中找到该函数并编辑其内容。将您的信息放在"中。