Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
IIS,PHP,MySQLi Max Execution Time exceeded
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Marlboro20" data-source="post: 298996" data-attributes="member: 40837"><p><strong>Hello community i need some help with my database class.</strong></p><p></p><p>I am sure this is an issue with IIS or PHP-CGI but i am not sure <img src="/styles/default/xenforo/smilies/emojione/frown.png" class="smilie" loading="lazy" alt=":(" title="Frown :(" data-shortname=":(" /></p><p></p><p>Here is the error i am receiving</p><p>[CODE]</p><p>PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\lib\database.php</p><p>[/CODE]</p><p>Here is the code that is causing the error</p><p>[PHP]</p><p><?php</p><p> /*</p><p> * Runs a query in the database.</p><p> * @returns (object) mysqli object result || False</p><p> */</p><p> public function query($sql)</p><p> {</p><p> // The line below $result = $this->connection->query($this->connection); causes the error.</p><p> if(!$result = $this->connection->query($sql))</p><p> {</p><p> throw new Exception(mysqli_error($this->connection));</p><p> }</p><p> return $result;</p><p> }</p><p>?></p><p>[/PHP]</p><p> </p><p></p><p>Here is my hole database class</p><p>[SPOILER]</p><p>[PHP]</p><p><?php</p><p> /**</p><p> * Database Layer.</p><p> *</p><p> */</p><p> </p><p> class database implements interfaces\database</p><p> {</p><p> protected $connection = null;</p><p></p><p> public function __call($function, $arguments)</p><p> {</p><p> if($connection == null)</p><p> {</p><p> $this->connect();</p><p> }</p><p> </p><p> if(method_exists($this, $function))</p><p> {</p><p> call_user_func_array(array($this, $function), $arguments);</p><p> }</p><p> }</p><p> public function __sleep()</p><p> {</p><p> $this->disconnect();</p><p> }</p><p> public function __wakeup()</p><p> {</p><p> $this->connect();</p><p> }</p><p></p><p> /**</p><p> * Creates a new database connection</p><p> * @return void</p><p> */</p><p> public function connect()</p><p> {</p><p> global $configuration;</p><p></p><p> $this->connection = new mysqli(</p><p> $configuration['mysql']['hostname'],</p><p> $configuration['mysql']['username'],</p><p> $configuration['mysql']['password'],</p><p> $configuration['mysql']['database']</p><p> );</p><p> $this->connection->set_charset("utf8");</p><p> </p><p> if(mysqli_connect_errno())</p><p> {</p><p> throw new Exception(mysqli_connect_error());</p><p> }</p><p> }</p><p> /**</p><p> * Disconnects the database connection</p><p> * @return void</p><p> */</p><p> public function disconnect()</p><p> {</p><p> if($this->connection !== null)</p><p> {</p><p> $this->connection->close();</p><p> }</p><p> $this->connection = null;</p><p> }</p><p> /*</p><p> * Runs a query in the database.</p><p> * @returns (object) mysqli object result || False</p><p> */</p><p> public function query($sql)</p><p> {</p><p> if(!$result = $this->connection->query($sql))</p><p> {</p><p> throw new Exception(mysqli_error($this->connection));</p><p> }</p><p> return $result;</p><p> }</p><p> /**</p><p> * Returns the amount of rows in a table.</p><p> * @return (int) row count.</p><p> */</p><p> public function num_rows($query)</p><p> {</p><p> if($result = $this->query($query))</p><p> {</p><p> return (int) $result->num_rows;</p><p> }</p><p> }</p><p> /**</p><p> * Returns the first row in the array.</p><p> * @return (string) of first array key.</p><p> */</p><p> public function result($query)</p><p> {</p><p> if($result = $this->fetch_array($query, MYSQLI_NUM))</p><p> {</p><p> return (string) $result[0][0];</p><p> }</p><p> }</p><p> /**</p><p> * Returns an array of rows from a table in the database.</p><p> * @return (array) $results</p><p> */</p><p> public function fetch_array($query, $type = MYSQLI_BOTH)</p><p> {</p><p> $results = array();</p><p> </p><p> while($row = $this->query($query)->fetch_array($type))</p><p> {</p><p> $results[] = $row;</p><p> }</p><p> </p><p> return $results;</p><p> $results->free();</p><p> }</p><p> /**</p><p> * Returns an associative array of rows from the database</p><p> * @return (array)(assoc)</p><p> */</p><p> public function fetch_assoc($query)</p><p> {</p><p> return $this->fetch_array($query, MYSQLI_ASSOC);</p><p> }</p><p> }</p><p>[/PHP]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="Marlboro20, post: 298996, member: 40837"] [B]Hello community i need some help with my database class.[/B] 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 [/CODE] 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; } ?> [/PHP] Here is my hole database class [SPOILER] [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); } } [/PHP] [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
IIS,PHP,MySQLi Max Execution Time exceeded
Top