I have 9 tables. I created a recoursive ajax function called nTables times (each for table) And into the ajax I call action.php with performed the search into every table.
The problem is that while performing the search, when I hit SHOW PROCESSLIST; in mysql, only have one Query running at time. And in my frontend page, the searches are performed one after another and not at the same time.
What can I do in order to mysql creates 9 connections at a time?
Here is my ajax:
function rAjax(thetables, i, thesearch){
i++;
$("#treethetables").hide();
$("#divsearching").show("slow", function() {});
var thetable=thetables[i];
if(i<thetables.length){
$.ajax({
type: "POST",
url: "app/action.php",
data: ({
txtBusca : thesearch,
thetable: thetable,
}),
beforeSend: function(){
$("#"+thetable).html("searching in "+thetable+"...");
},
success: function(data){
totalOkTables--;
console.warn(totalOkTables);
if(totalOkTables==0){
$("#divsearching").hide();
$("#treethetables").show("slow", function() {});
}
$("#"+thetable).append(data)
}
});
rAjax(thetables, i, thesearch)
}
}
And here is my deffinition of the connection:
class vitDb{
private $conn=NULL;
private $db=NULL;
private $selectdb=NULL;
public $dbase;
public function vitDb(){
$hostname_conn = "127.0.0.1";
$database_conn = "myBase";
$username_conn = "root";
$password_conn = "";
$this->conn = mysql_connect($hostname_conn, $username_conn, $password_conn, true) or trigger_error(mysql_error(),E_USER_ERROR);
$this->selectdb = mysql_select_db($database_conn, $this->conn);
$this->db=$database_conn;
}
public function QSet($sql){//Regresa el Juego aunque esté vacío, y NULL si error.
if($theSet=mysql_query($sql, $this->conn)){
return $theSet;
}else{
return NULL;
}
}
}
And the call:
$my = new vitDb();
$db=$my->dbase;
$sql="SELECT * FROM $tabla WHERE ...";
$res=$my->QSet($sql);
#Staff
Hope Can help me thanks.