I have some reports where I need to perform new SQL queries in the loop. These reports are running on PHP and datatables.
At times, when the number of rows reaches a volume greater than 1000, the MSSQL: SQLSTATE [] (null) (severity 0) error is displayed, aborting code execution.
Connection function:
function pdo_mysql($sql){
f_log($sql);
$host = ***;
$user = ***;
$pass = ***;
$db = ***;
try {
$PDO = new PDO( 'mysql:host=' . $host . ';dbname=' . $db, $user, $pass );
}
catch ( PDOException $e ) {
echo 'Erro ao conectar com o MySQL: ' . $e->getMessage(); exit;
}
$result = $PDO->query( $sql );
if (is_array($result)){
$row = $result->fetchAll( PDO::FETCH_ASSOC );
}else{
$row = $result;
}
return $row;
}
Template of problem file:
$sql = "SELECT ....";
$return = pdo_mssql($sql);
foreach ($return as $row){
$sql2 = "SELECT ...."
$return = pdomssql($sql2);
foreach ($return2 as $row2){
// Guarda dados em variáveis.
}
$sql2 = "SELECT ...."
$return = pdomssql($sql2);
foreach ($return2 as $row2){
// Guarda dados em variáveis.
}
$sql2 = "SELECT ...."
$return = pdomssql($sql2);
foreach ($return2 as $row2){
// Guarda dados em variáveis.
}
// Exibe resultados
}
Has anyone ever had anything like this or do you have any suggestions?
Thank you