$app->get(’/api/product/sku’,function( $request, $response){
//get db object
$db = new db();
//connect
$db = $db->connect();
$toto = array();
$tata = array();
$result =array();
$sqlproducts = "SELECT * FROM products ";
$resultproducts = $db->query($sqlproducts);
while($rowproducts = $resultproducts->fetch(\PDO::FETCH_ASSOC) ){
$toto[]= $rowproducts;
$sqlskus = "SELECT * FROM sku " ;
$resultsku = $db->query($sqlskus);
while($rowsku = $resultsku->fetch(\PDO::FETCH_ASSOC)){
$tata []=$rowsku;
$result = array_merge($array1, $array2);
echo json_encode($result);
}
}
}) ;
the result is nullnullnullnullnullnullnullnullnull
You should check $resultproducts:
if ($resultproducts > 0) {
// got data
} else {
// no data
}
Mind you, this is has nothing to do with Slim.