IIS,PHP,MySQLi Max Execution Time exceeded

Marlboro20

Member
Dec 17, 2013
37
6
Hello community i need some help with my database class.

I am sure this is an issue with IIS or PHP-CGI but i am not sure :(

Here is the error i am receiving
Code:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\lib\database.php
Here is the code that is causing the error
PHP:
<?php
        /*
         * Runs a query in the database.
         * @returns (object) mysqli object result || False
         */
        public function query($sql)
        {
            // The line below $result = $this->connection->query($this->connection); causes the error.
            if(!$result = $this->connection->query($sql))
            {
                throw new Exception(mysqli_error($this->connection));
            }
            return $result;
        }
?>


Here is my hole database class
PHP:
<?php
    /**
    *    Database Layer.
    *
    */
   
    class database implements interfaces\database
    {
        protected $connection    = null;

        public function __call($function, $arguments)
        {
            if($connection == null)
            {
                $this->connect();
            }
           
            if(method_exists($this, $function))
            {
                call_user_func_array(array($this, $function), $arguments);
            }
        }
        public function __sleep()
        {
            $this->disconnect();
        }
        public function __wakeup()
        {
            $this->connect();
        }

        /**
         * Creates a new database connection
         * @return void
         */
        public function connect()
        {
            global $configuration;

            $this->connection = new mysqli(
                $configuration['mysql']['hostname'],
                $configuration['mysql']['username'],
                $configuration['mysql']['password'],
                $configuration['mysql']['database']
            );
            $this->connection->set_charset("utf8");
           
            if(mysqli_connect_errno())
            {
                throw new Exception(mysqli_connect_error());
            }
        }
        /**
         * Disconnects the database connection
         * @return void
         */
        public function disconnect()
        {
            if($this->connection !== null)
            {
                $this->connection->close();
            }
            $this->connection = null;
        }
        /*
         * Runs a query in the database.
         * @returns (object) mysqli object result || False
         */
        public function query($sql)
        {
            if(!$result = $this->connection->query($sql))
            {
                throw new Exception(mysqli_error($this->connection));
            }
            return $result;
        }
        /**
         * Returns the amount of rows in a table.
         * @return (int) row count.
         */
        public function num_rows($query)
        {
            if($result = $this->query($query))
            {
                return (int) $result->num_rows;
            }
        }
        /**
         * Returns the first row in the array.
         * @return (string) of first array key.
         */
        public function result($query)
        {
            if($result = $this->fetch_array($query, MYSQLI_NUM))
            {
                return (string) $result[0][0];
            }
        }
        /**
         * Returns an array of rows from a table in the database.
         * @return (array) $results
         */
        public function fetch_array($query, $type = MYSQLI_BOTH)
        {
            $results = array();
       
            while($row = $this->query($query)->fetch_array($type))
            {
                $results[] = $row;
            }
       
            return $results;
            $results->free();
        }
        /**
         * Returns an associative array of rows from the database
         * @return (array)(assoc)
         */
        public function fetch_assoc($query)
        {
            return $this->fetch_array($query, MYSQLI_ASSOC);
        }
    }
 

Marlboro20

Member
Dec 17, 2013
37
6
Code:
   class database implements interfaces\database
wat
i use the SPR-0 autoload standards so my file is located at
C:\inetpub\wwwroot\lib\database.php
and it uses the database interface located at
C:\inetpub\wwwroot\lib\interfaces\database.php


And it was the interface :( thanks though problem fixed
 
Last edited:

Users who are viewing this thread

Top