MySQL - SELECT COUNT (*) - Forum

Forum Navigation
You need to log in to create posts and topics.

MySQL - SELECT COUNT (*)

Hi..

I run this query but i don't know where to look for the results.

$sqlAlias[30]="SelectCountServices";
$sqlQuerys[30]="SELECT (SELECT COUNT(*) FROM Services WHERE status = 'active') AS Active_Ads_Count, (SELECT COUNT(*) FROM Services WHERE status = 'progress') AS In_Progress_Ads, (SELECT COUNT(*) FROM Services WHERE status = 'com') AS Contact_Info_Requested_Ads, (SELECT COUNT(*) FROM Services WHERE status = 'finished') AS Completed_Ads";
$sqlMaxUserLevel[30]=-1;

I nvoke the query from this line

neoPhpExecSql "servicefinder" "SelectCountServices" "" "CountServices"

What i should put in Countservices subroutine in order to read all the variables ?

 

@smartmedia when in doubt use ConsoleLog to print the data you get from the server in the Console.
Examining the coming data is usually very easy to see if it's a single number, string or an Array.
Let me know if you need additional information.

Regards.

Hi @luishp

When i run it locally using the [CountServices] i don't receive any error or message with ConsoleLog.

When i test it on server i get a n error. It shown on the photo ?

Uploaded files:
  • You need to login to have access to uploads.

@smartmedia I have not enough information to help you.
Does the callback subroutine execute at all? (you can add a jsAlert to be sure)
If the subroutine is executed then any kind of data must be received from the server.
If the subroutine is not executed then please double check database name alias, query alias and subroutine name.
Any other query is executed correctly?

Regards.

Hi @luishp

After some tests i made i discover that if the query has hardcore values inside the config.php and the neoPhpExecSql hasn't any parameters the query will NOT executed.

Second observation is that, if the query has (SELECT COUNT(*) FROM Services WHERE status = 'active') AS Active_Ads_Count

the AS Active_Ads_Count wil NOT run the query.

And third observation is that finally i get some result only if i have parameters in neoPhpExecSql and only if the AS Active_Ads_Count is deleted from the query. The other thing is that for some reason all the query is the first part of the string, check the photo. So from where i will get the values ?

Count (*) is a must function and i want to have it. Any ideas ?

 

 

Uploaded files:
  • You need to login to have access to uploads.

Hi @smartmedia

Here is an example with select count, hope this help you

config.php :

$sqlAlias[27]="countT2";
$sqlQuerys[27]="SELECT count(J2G) as nbJ, 2 as nT FROM mt_tour2 WHERE ID = ?";
$sqlMaxUserLevel[27]=-1;

Calling count :

neoPhpExecSql "dbMT" "countT2" "[nID]" "TirageEffectue"

subroutine TirageEffectue (parameter [resp] type string ) :

CreateEmptyObject [MyT]
SetVar [MyT] [resp]
If [MyT(0).nbJ] > 0
SetVar [nTour] [MyT(0).nT]
Setvar [Select] "selectT[nTour]"
SetVar [aTirage([nTour])] true
If [nTour] == 2
neoPhpExecSql "dbMT" "[Select]" "[nID]" "LoadT2"

smartmedia has reacted to this post.
smartmedia

Hi @phil78

I didint had the time to check it out cause i am in involved in some other part of the code. As soon as i check it i let you know, thanks.