Czytałem, stosowałem, ale nie pomaga:
public function test() {
$q = $this->lacz->query("SELECT count(id) FROM informacje");
$res = $q->fetch_array();
1=> ".$res[0];
if ($this->lacz->multi_query("SELECT id FROM informacje;SELECT id FROM informacje;")) echo " 2=> false";
while ($this->lacz->next_result()) {if (!$this->lacz->more_results()) break;}
$q1 = $this->lacz->query("SELECT count(id) FROM informacje");
$res = $q1->fetch_array();
3=> ".$res[0];
}
a odpowiedzi:
Kod
object(mysqli_result)#3 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(1)
["lengths"]=>
NULL
["num_rows"]=>
int(1)
["type"]=>
int(0)
}
1=> 8194bool(true)
2=> falsebool(false)
Fatal error: Call to a member function fetch_array() on a non-object...
a powinno być: 3=> 8194
Aha... zrzut var_dump($this->lacz);
Kod
object(mysqli)#2 (19) {
["affected_rows"]=> int(0)
["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503"
["client_version"]=> int(50011)
["connect_errno"]=> int(0)
["connect_error"]=> NULL
["errno"]=> int(0)
["error"]=> string(0) ""
["error_list"]=> array(0) { }
["field_count"]=> int(0)
["host_info"]=> string(37) "localhost via TCP/IP"
["info"]=> NULL
["insert_id"]=> int(0)
["server_info"]=> string(18) "5.5.43-MariaDB-log"
["server_version"]=> int(50543)
["stat"]=> string(157) "Uptime: 1593698 Threads: 8 Questions: 1080197386 Slow queries: 98149 Opens: 36678366 Flush tables: 2 Open tables: 1024 Queries per second avg: 677.793"
["sqlstate"]=> string(5) "00000"
["protocol_version"]=> int(10)
["thread_id"]=> int(21916318)
["warning_count"]=> int(0) }
Więc połączenie z bazą jest prawidłowe.