I have come across an odd issue that I don't know how to resolve. I am using Angular, PHP Slim Restful API, MySQL db.
Two of my db tables have 1k + rows.
When I try to query these tables I get a 500 Internal Server Error from Angular. If I drop the table rows down to below 50 the query works with no errors.
HOWEVER, when I am on my local drive (dev site) I can query the tables with 1k + rows with no problems.
Does anyone have any ideas why this is happening and a solution?
EDIT : here is the code to query the db. The while loop does not run
try{
$a = array();
$w = "";
$row_data = array();
foreach ($where as $key => $value) {
$w .= " and " .$key. " like :".$key;
$a[":".$key] = $value;
}
$stmt = $this->db->prepare("select ".$columns." from ".$table." where 1=1 ". $w);
$stmt->execute($a);
//$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$row_count = $stmt->rowCount();
syslog(LOG_WARNING, "DATA COUNT= ".print_r($row_count,true));
if(count($row_count)<=0){
syslog(LOG_WARNING, "DATA NO ROWS");
$response["status"] = "warning";
$response["message"] = "No data found.";
}else{
$response["status"] = "success";
$response["message"] = "Data selected from database";
syslog(LOG_WARNING, "DATA HAVE ROWS");
===================
while ($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
$row_data[] = $rows;
}
===================
syslog(LOG_WARNING, "DATA JASON= ".print_r($row_data,true));
$response["data"] = $row_data;
}
syslog(LOG_WARNING, "DATA END");
}catch(PDOException $e){
$response["status"] = "error";
$response["message"] = 'Select Failed: ' .$e->getMessage();
$response["data"] = null;
}
return $response;