Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

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

  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 11 months ago #151280 by blocka
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:
Code:
$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?
The topic has been locked.
  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 11 months ago #151281 by blocka
Ah, figured it out, query needs to be:

$currentSurveys = Yii::app()->db->createCommand($currentSurveysQuery)->queryScalar();
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago - 6 years 11 months ago #151306 by DenisChenu
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 , plugin development .
I don't answer to private message.
Last edit: 6 years 11 months ago by DenisChenu.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose