I am new to php
and SQL
.
I have a database with 45 000 rows, I need to extract all 'udid' attribute, so there is a lot of data. I put the result in an array, for each udid, I check if udid.xml exists, if the file exist i open it and search for some data, then i reorder the array..While this process I get a timeout error, when I call my script or a 504 error from my internet provider.
Here is my php code :
include("myFunctions.php");
header('Content-type: application/json; charset=utf-8');
$handle = fopen('php://input','r');
// ----------
set_time_limit (0);
$req_Push = $db->sql_query("SELECT * FROM utilisateurs");
echo("COUNT = " .$db->sql_numrows($req_Push). "");
$arrayBigTbl = array();
while ($row_Push = $db->sql_fetchrow($req_Push)){ // while udid ref fichier utilisateurs
$idUser = $row_Push['udid'];
$arrayBigTbl []= $idUser;
}
//print_r($arrayBigTbl);
echo("</br>Count array global = " .count($arrayBigTbl). "--");
$arrayBigTbl = array_unique($arrayBigTbl);
echo("</br>Count array global nettoyée = " .count($arrayBigTbl). " -- Fin2");
$arrayXMLDevice = array();
for ($i = 0; $i < count($arrayBigTbl) ; $i++)
{
if (deviceXMLExist($arrayBigTbl[$i]))
{
$UDIDFile = simplexml_load_file("./UDID/".$arrayBigTbl[$i].".xml");
foreach($UDIDFile->UDID as $item)
{
$valueTemp = $item->valueUDID;
$strig = "" .$valueTemp. "";
$arrayXMLDevice[] = $strig;
}
}
}
//print_r($arrayXMLDevice);
echo("COUNT ARRAY DEVICE XML = " .count($arrayXMLDevice). " --- Fin 3");
$arrayXMLDevice = array_unique($arrayXMLDevice);
echo("COUNT ARRAY DEVICE XML = " .count($arrayXMLDevice). " --- Fin 3");
$arrayXMLDevice = array_values($arrayXMLDevice);
$arraymerge = array_merge ( $arrayBigTbl,$arrayXMLDevice );
echo("COUNT ARRAY MERGE = " .count($arraymerge). " --- </br>");
$arraymerge = array_unique($arraymerge);
echo("COUNT ARRAY MERGE NETTOYEE = " .count($arraymerge). " --- Fin 3");
$arrayFinalPush = array();
for ($i = 0; i < count($arraymerge);$i=$i+1)
{
$aValue = $arraymerge[i];
if(ctype_xdigit($deviceToken) && strlen($deviceToken)>60)
{
$arrayFinalPush[] = $aValue;
}
}
echo("COUNT ARRAY FINAL = " .count($arrayFinalPush). " ---");
How can I resolve this problem so my request gets finished?