示例#1
0
 /**
  * @param int|string $formID Form ID.
  */
 public function __construct($formID)
 {
     parent::__construct();
     $this->fDBName = FormConstructor::getDatabase();
     $this->tableName = QAL::getFQTableName($this->fDBName . '.' . self::TABLE_PREFIX . $formID);
     $this->dbh->modify('CREATE TABLE IF NOT EXISTS ' . $this->tableName . ' (pk_id int(10) unsigned NOT NULL AUTO_INCREMENT,form_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`pk_id`), INDEX(form_date)) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ');
 }
示例#2
0
 /**
  * @copydoc Grid::__construct
  */
 public function __construct($name, array $params = null)
 {
     parent::__construct($name, $params);
     //Якщо ідентифікатор форми вказаний невірно або не вказаний, то не вивалювати помилку, а красиво показати.
     if (!($this->formID = $this->getParam('form_id'))) {
         $this->formID = false;
     } else {
         $this->setTableName(FormConstructor::getDatabase() . '.form_' . $this->formID);
     }
     $this->setOrder(array('pk_id' => QAL::DESC));
 }
示例#3
0
 /**
  * @copydoc DBDataSet::__construct
  */
 public function __construct($name, array $params = NULL)
 {
     parent::__construct($name, $params);
     $filter = ['form_is_active' => 1];
     if ($formID = $this->getParam('id')) {
         $filter['form_id'] = $formID;
     }
     $this->formID = $this->dbh->getScalar('frm_forms', 'form_id', $filter, 'RAND()', 1);
     //If formID is actual number, but we don't have table with name form_$formID, then set formID to false.
     //Otherwiste setTableName.
     if (!$this->formID || !$this->dbh->tableExists($tableName = FormConstructor::getDatabase() . '.' . FormConstructor::TABLE_PREFIX . $this->formID)) {
         $this->formID = false;
     } else {
         $this->setTableName($tableName);
     }
     $this->setType(self::COMPONENT_TYPE_FORM_ADD);
     $this->setAction('send');
     $this->addTranslation('TXT_ENTER_CAPTCHA');
 }
示例#4
0
 /**
  * @copydoc Grid::deleteData
  */
 protected function deleteData($id)
 {
     parent::deleteData($id);
     $res = $this->dbh->select('SHOW FULL TABLES FROM `' . FormConstructor::getDatabase() . '` LIKE "%form_' . $id . '%"');
     if (is_array($res)) {
         $tables = array_map(function ($row) {
             return current($row);
         }, $res);
         $this->dbh->modify('SET FOREIGN_KEY_CHECKS=0;');
         foreach ($tables as $tableName) {
             $this->dbh->modify('DROP TABLE `' . FormConstructor::getDatabase() . '`.' . $tableName);
         }
     }
 }