How to check for total # of surveys in an LS Instance?

More
1 year 6 months ago #151280 by blocka
blocka created the topic: How to check for total # of surveys in an LS Instance?
I want to be able to show all LS users the total # of surveys currently in an LS instance.

I would have figured that this would return that value:
$currentSurveysQuery = "SELECT count(*) FROM {{surveys}}";
$currentSurveys = Yii::app()->db->createCommand($currentSurveysQuery)->queryAll();

But if I log in as a new user who can only create surveys (and not see all surveys), the above query returns "0" -- even if there are 50 surveys in the LS instance.

Can anyone point me to what I'm doing wrong?

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #151281 by blocka
blocka replied the topic: How to check for total # of surveys in an LS Instance?
Ah, figured it out, query needs to be:

$currentSurveys = Yii::app()->db->createCommand($currentSurveysQuery)->queryScalar();

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago - 1 year 6 months ago #151306 by DenisChenu
DenisChenu replied the topic: How to check for total # of surveys in an LS Instance?
Did you try Survey::model()->count(); ?


[edit] www.yiiframework.com/doc/api/1.1/CActiveRecord#count-detail

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 1 year 6 months ago by DenisChenu.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!