Notifications
Retirer tout
Ask questions
2
Posts
2
Utilisateurs
0
Reactions
1,691
Vu
Début du sujet
Hi,
I am trying to create a custom report but I got a error really strange.
Error :
2020-03-19 14:58:18.888 ** ERROR ** [V8.3.2] on file 'C:wamp64wwwipmp_newreportheaderFunctions.php' at line (54) 2020-03-19 14:58:18.893 ** ERROR ** [V8.3.2] cause = count(): Parameter must be an array or an object that implements Countable
Here is the code which produce the bug :
$queryWhere = ($queryWhere == '') ? ' 1=1' : $queryWhere;
$query = 'select ' . $querySelect
. ' from ' . $queryFrom
. ' where ' . $queryWhere;
$result = Sql::query($query);
if (checkNoData($result)) exit; // The error occurs in that function
The variable $query contains this query :
select `id`, DATE_FORMAT(`externalValidation`, '%Y%m%d') `delivered`, DATE_FORMAT(`externalValidationScheduled`, '%Y%m%d') `planned`, DATE_FORMAT(`externalValidation`, '%Y-%m') `interval` from `document` where `idProject` IN (0, 100) AND `externalValidationScheduled` IS NOT NULL AND `externalValidation` BETWEEN '2020-03-01' AND '2021-02-28' AND `idDocumentType` = '63'
When I run this query in PHP my admin it return 0 row but no error.
The begin of function checkNoData :
function checkNoData($result, $month=null) {
global $outMode;
if (count($result)==0) { // Error is thrown here
The $result parameter :

I don't understand why the Sql::query doesn't return proper value :'(
Posté : 19/03/2020 5:13 pm
checkNoData() expects an array as parameter.
You send a resource to a query.
Posté : 19/03/2020 9:44 pm