php - connected to mysql table depending on time -


if server time between 1-30 second connect 1 table , if more 31-60 seconds connect table.

reason why need because im not sure if 10,000 people accessing single mysql table slow down dramatically.

my code below

 <?php     header('content-type: application/json');      $server = "localhost";     $username = "root1";     $password = "root1";     $database = "test";      $con = mysql_connect($server, $username, $password) or die ("could not connect: " .  mysql_error());     mysql_select_db($database, $con);      $sql = "select id, name post order id";     $result = mysql_query($sql) or die ("query error: " . mysql_error());      $records = array();      while($row = mysql_fetch_assoc($result)) {         $records[] = $row;     }      mysql_close($con);      echo $_get['jsoncallback'] . '(' . json_encode($records) . ');';     ?> 

you can set connection timeout 1 of options. see: http://php.net/manual/en/mysqli.options.php


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -