/** * Returns an instance of class (singleton pattern implementation). * * @return EQUESTIONS_BOL_OptionDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
private function copyData() { $tables = array(array(QUESTIONS_BOL_QuestionDao::getInstance()->getTableName(), EQUESTIONS_BOL_QuestionDao::getInstance()->getTableName(), array('id', 'userId', 'text', 'settings', 'timeStamp')), array(QUESTIONS_BOL_OptionDao::getInstance()->getTableName(), EQUESTIONS_BOL_OptionDao::getInstance()->getTableName(), array('id', 'userId', 'questionId', 'text', 'timeStamp')), array(QUESTIONS_BOL_AnswerDao::getInstance()->getTableName(), EQUESTIONS_BOL_AnswerDao::getInstance()->getTableName(), array('id', 'userId', 'optionId', 'timeStamp')), array(QUESTIONS_BOL_FollowDao::getInstance()->getTableName(), EQUESTIONS_BOL_FollowDao::getInstance()->getTableName(), array('id', 'userId', 'questionId', 'timeStamp')), array(QUESTIONS_BOL_ActivityDao::getInstance()->getTableName(), EQUESTIONS_BOL_ActivityDao::getInstance()->getTableName(), array('id', 'questionId', 'activityType', 'activityId', 'userId', 'timeStamp', 'privacy', 'data'))); foreach ($tables as $t) { OW::getDbo()->query('REPLACE INTO ' . $t[1] . ' (`' . implode('` ,`', $t[2]) . '`) SELECT `' . implode('` ,`', $t[2]) . '` FROM ' . $t[0]); } }
public function findOptionCount($questionId) { return $this->optionDao->findCountByQuestionId($questionId); }
public function findMaxCountByQuestionId($questionId) { $optionDao = EQUESTIONS_BOL_OptionDao::getInstance(); $query = 'SELECT count(a.id) FROM ' . $this->getTableName() . ' a ' . 'INNER JOIN ' . $optionDao->getTableName() . ' o ON a.optionId=o.id ' . 'WHERE o.questionId=:q GROUP BY o.id ORDER BY count(a.id) DESC limit 1'; return (int) $this->dbo->queryForColumn($query, array('q' => $questionId)); }