/** * {@inheritdoc} * @codeCoverageIgnore */ public function setSchema($prune = false) { // Reimplementation to provide a view instead of previous table $logger = $this->_serviceLocator->get('Library\\Logger'); $database = $this->_serviceLocator->get('Database\\Nada'); if (in_array('download_enable', $database->getTableNames())) { // Use value of "fileid" column instead of obsolete "id" for package assignments $logger->info('Transforming package assignment IDs...'); $where = new \Zend\Db\Sql\Where(); $this->_serviceLocator->get('Database\\Table\\ClientConfig')->update(array('ivalue' => new \Zend\Db\Sql\Expression(sprintf('(SELECT CAST(fileid AS %s) FROM download_enable WHERE id = ivalue)', $database->getNativeDatatype(Column::TYPE_INTEGER, 32, true)))), $where->notEqualTo('name', 'DOWNLOAD_SWITCH')->like('name', 'DOWNLOAD%')); $logger->info('done.'); $logger->info("Dropping table 'download_enable'..."); $database->dropTable('download_enable'); $logger->info('done.'); } if (!in_array('download_enable', $database->getViewNames())) { $logger->info("Creating view 'download_enable'"); $typeText = $database->getNativeDatatype(Column::TYPE_VARCHAR, 255, true); $typeInt = $database->getNativeDatatype(Column::TYPE_INTEGER, 32, true); $null = 'CAST(NULL AS %s)'; $sql = $this->_serviceLocator->get('Database\\Table\\Packages')->getSql(); $select = $sql->select(); $select->columns(array('id' => 'fileid', 'fileid' => 'fileid', 'info_loc' => new Literal("(SELECT tvalue FROM config WHERE name = 'BRAINTACLE_DEFAULT_INFOFILE_LOCATION')"), 'pack_loc' => new Literal("(SELECT tvalue FROM config WHERE name = 'BRAINTACLE_DEFAULT_DOWNLOAD_LOCATION')"), 'cert_path' => new Literal(sprintf($null, $typeText)), 'cert_file' => new Literal(sprintf($null, $typeText)), 'server_id' => new Literal(sprintf($null, $typeInt))), false); $database->createView('download_enable', $sql->buildSqlString($select)); $logger->info('done.'); } }
public function getUsersByEmail($email, $id = 0) { $where = new \Zend\Db\Sql\Where(); $where->notEqualTo('id', (int) $id); $where->equalTo('email', $email); $rowset = $this->select($where); $row = $rowset->current(); if (!$row) { return false; } return $row; }
private function dropdownMenus($id = 0) { $options = array(); if (empty($id)) { $select = new Select(); $where = new \Zend\Db\Sql\Where(); $where->notEqualTo('id', (int) $id); $select->where($where); $options = $this->getMenusTable()->dropdownMenus($select); } else { $options = $this->getMenusTable()->dropdownMenus(); } return $options; }