0
В настоящее время я застрял ..количество участников. Количество выходных массивов?
При попытке выборки рассчитывать член возвращается в виде массива, который не так легко вывести, когда это число .. вот код
Member.php
public function __construct() { $this->_pdo = DB::connect(); }
public function count() {
$this->_query = $this->_pdo->query("SELECT COUNT(*) FROM members");
if(!$this->_query->error()) {
print_r($this->_query);
}
return false;
}
DB.php
private function __construct() {
try {
$this->pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/dbname'), Config::get('mysql/username'), Config::get('mysql/password'));
} catch(PDOException $e) {
die($e->getMessage());
}
}
public static function connect() {
if(!isset(self::$_connect)) {
self::$_connect = new DB();
}
return self::$_connect;
}
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;
}
Как это сделать правильно?
Это уже сделано в функции $ this -> _ pdo-> query(). Могу ли я сделать это дважды? –
где уже сделано? – Federkun
обновил вопрос, вы можете видеть там =) –