简体   繁体   English

mysqli php扩展

[英]mysqli php extend

i was wondering if you could point me in the right direction. 我想知道你是否能指出我正确的方向。 Im extending the mysqli class but cant seem to call the error function.. 我扩展了mysqli类,但似乎无法调用错误函数..

<?php

class mysqli_ls extends mysqli
{
   private $activeConnection = 0;
   private $linkArr  = array();
   private $queryArr = array();
   private $errorArr = array();  

   public function __construct()
   {
   }

/* Connection ************************************************************ */

   public function connect($host='', $username='', $password='', $port='', $database='')
   {
      $no =& $this->activeConnection;
      $no++;

      if ( empty($host) || empty($username) || empty($password) || empty($port) || empty($database) )
      {
         $this->setError('1', 'connect','missing required variables');
         return false;
      }

      $this->linkArr[ $no ] = parent::mysqli($host,$username,$password);

      if ( $this->linkArr[ $no ] === false )
      {
         $this->setError(2, 'connect', parent::error( $this->linkArr[ $no ] ) );
         return false;
      }

      return $no;
   }

Fatal error: Call to undefined method mysqli::error() in C:\\wamp\\www\\vhdocs\\test\\mysqli.class.php on line 31 致命错误:在第31行的C:\\ wamp \\ www \\ vhdocs \\ test \\ mysqli.class.php中调用未定义的方法mysqli :: error()

i've also tried parent::mysqli_error and had the same error... I cant see why i cant call the error..... 我也尝试过parent :: mysqli_error并遇到相同的错误...我看不到为什么我无法调用该错误.....

Try $this->error (it's a property, not a function in OO style). 试试$this->error (它是一个属性,而不是OO风格的函数)。 See also the examples at the php manual 另请参见php手册中示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM