已修复:问题是由于某种原因,web服务器上的spl_autoloader剂量工作正常,并且我的代码中有一种typeo可以在我的机器上工作,但不能在Web服务器上工作。
尝试解决其网站在我的计算机上正常运行的问题,而不是在Google托管的VM上解决问题。
数据库可以接收数据,但是我似乎无法通过JSON POST请求显示数据或通过登录系统登录。
我感觉数据库没有将数据“发送”到PDO。
是否有日志或我可以做的事情来检查对数据库的请求?
系统信息:http://www.interplanetaryhub.com/phpinfo.php
可以在我的计算机上运行的数据库连接代码,但不能在Webhost VM上运行
<?php
class Database {
private static $_instance = null;
private $_pdo,
$_query,
$_error = false,
$_results,
$_count = 0;
private function __construct() {
try {
$this->_pdo = new PDO('mysql:host='.Config::get('mysql/host').';dbname='.Config::get('mysql/db'),Config::get('mysql/username'),Config::get('mysql/password'));
} catch (PDOException $e) {
die($e->getMessage());
}
}
public static function getInstance() {
if (!isset(self::$_instance)) {
self::$_instance = new Database();
}
return self::$_instance;
}
public function query($sql, $params = array()) {
$this->_error = false;
if ($this->_query = $this->_pdo->prepare($sql)) {
$x = 1;
if (count($params)) {
foreach ($params as $param) {
$this->_query->bindValue($x, $param);
$x++;
}
}
if ($this->_query->execute()) {
$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
$this->_count = $this->_query->rowCount();
} else {
$this->_error = true;
}
}
return $this;
}