Controller:

<?php namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; use Application\Common\CommonServices; use Application\Common\MySQL; class IndexController extends AbstractActionController{ var $sqln; public function __construct() { $this->$sqln=new MySQL(); $this->$sqln->connect("localhost",'root','ввв','222'); } 

MySQL class:

 <?php namespace Application\Common; class MySQL { var $idsqlconnection; var $query_result; var $num_queries = 0; function connect($host, $name, $pass, $base,$codemysql="utf8"){ $this->idsqlconnection = new mysqli($host, $name, $pass, $base); ... 

When you call the $ this -> $ sqln-> connect command from __construct (), connect ("localhost", 'root', 'wbv', '222') ;, Zend Framework 3 crashes with the error:

 Error File: /var/www/webuseorg4/module/Application/src/Common/MySQL.php:22 Message: Class 'Application\Common\mysqli' not found 

    1 answer 1

    In this case, Mysqli is in a different namespace, so you need to call it from the "root": new \ mysqli ($ host, $ name, $ pass, $ base);