Lid |
|
Probleem al lichterlijk getekeld dee een FETCH ASSOC terwijl ik met index keys uitlas
Verbetere versie:
private function searchAllDB($search){
$out = Array();
$sql = "SHOW TABLES";
$rs = $this->registry->mysql->query($sql);
$rs->execute();
$i = 1;
if($rs->rowCount() > 0){
while($r = $rs->fetch(PDO::FETCH_BOTH)){
$table = $r[0];
/*
* Skip some Tables
*/
switch($table)
{
case "relations_backup":
continue 2;
break;
}
$sql_search = "SELECT * FROM ".$table." WHERE ";
$sql_search_fields = Array();
$sql2 = "SHOW COLUMNS FROM ".$table;
$rs2 = $this->registry->mysql->query($sql2);
$rs2->execute();
if($rs2->rowCount() > 0){
while($r2 = $rs2->fetch(PDO::FETCH_BOTH)){
$colum = $r2[0];
$sql_search_fields[] = $colum." LIKE('%".$search."%')";
}
}
$sql_search .= implode(" OR ", $sql_search_fields);
$rs3 = $this->registry->mysql->query($sql_search);
$rs3->execute();
if($rs3->rowCount() > 0){
$out[] = $table;
}
$i++;
}
}
return $out;
}
private function searchAllDB($search){ $sql = "SHOW TABLES"; $rs = $this->registry->mysql->query($sql); $rs->execute(); $i = 1; if($rs->rowCount() > 0){ while($r = $rs->fetch(PDO::FETCH_BOTH)){ $table = $r[0]; /* * Skip some Tables */ switch($table) { case "relations_backup": continue 2; break; } $sql_search = "SELECT * FROM ".$table." WHERE "; $sql_search_fields = Array(); $sql2 = "SHOW COLUMNS FROM ".$table; $rs2 = $this->registry->mysql->query($sql2); $rs2->execute(); if($rs2->rowCount() > 0){ while($r2 = $rs2->fetch(PDO::FETCH_BOTH)){ $colum = $r2[0]; $sql_search_fields[] = $colum." LIKE('%".$search."%')"; } } $sql_search .= implode(" OR ", $sql_search_fields); $rs3 = $this->registry->mysql->query($sql_search); $rs3->execute(); if($rs3->rowCount() > 0){ $out[] = $table; } $i++; } } return $out; }
|