我最近遇到了一个问题,我无法找到解决方案。 我有一个核心类,在其构造函数中包含以下代码:
x$xct <- cut( x$x, breaks=quantile(x$x, prob=c( seq(100, length(x$x), by=100)/length(x$x) , 1) ))
table(x$xct)
(4.64,5.17] (5.17,5.57] (5.57,5.85] (5.85,6.17] (6.17,6.51] (6.51,6.85]
100 100 100 100 100 100
(6.85,7.26] (7.26,7.94] (7.94,9.36]
100 100 62
正如您所看到的,我将对象存储在名为&#34; db&#34;
的属性中之后,我在运行给定查询的同一个类中创建了一个方法:
public function __construct()
{
$this->runDatabaseConnection();
$this->fetchSettings();
}
private function runDatabaseConnection()
{
global $config;
$this->db = new mysqli($config['db']['server'], $config['db']['user'], $config['db']['password'], $config['db']['name']);
$this->db->set_charset($config['db']['charset']);
}
现在课外,当我使用类似的东西时:
public function query($queryStr)
{
return $this->db->query($queryStr) or die($this->db->error.($this->debugMode ? '<br><b>Query: </b><i>'.$queryStr.'</i>' : ''));
}
$ studentsQuery变量似乎是一个布尔值,而不是我期待的资源,那么我缺少什么?提前谢谢。