private function initMySqlHandler() { $this->mysql = MySQL::instance(); $this->mysql->connect(array('pdoInstance' => $this->preferencesList->pdoInstance, 'host' => $this->preferencesList->mysqlHost, 'port' => $this->preferencesList->mysqlPort, 'user' => $this->preferencesList->mysqlUser, 'pass' => $this->preferencesList->mysqlPass, 'dbName' => $this->preferencesList->dbName, 'dbCharset' => $this->preferencesList->dbCharset)); if ($this->preferencesList->autoGenerateTables) { $schema = MySQLSchemaHandler::instance($this->preferences, $this->mysql->getHandler()); $schema->createDefaultSchema(); } }
public function removeUserFromRole($userId, $roleId) { if (User::instance($this->preferences, $this->db)->findById($userId) && Role::instance($this->preferences, $this->db)->findById($roleId)) { try { $sql = "DELETE FROM rpd_user_has_role WHERE id_user = :userId AND id_role = :roleId"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':userId', $userId, PDO::PARAM_INT); $stmt->bindParam(':roleId', $roleId, PDO::PARAM_INT); return $stmt->execute(); } catch (\PDOException $e) { MySQL::instance()->showException($e); } } return false; }
public function removeOperationFromTask($operationId, $taskId) { if (Task::instance($this->preferences, $this->db)->findById($taskId) && Operation::instance($this->preferences, $this->db)->findById($operationId)) { try { $sql = "DELETE FROM rpd_task_has_operation WHERE id_task = :taskId AND id_operation = :operationId"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':taskId', $taskId, PDO::PARAM_INT); $stmt->bindParam(':operationId', $operationId, PDO::PARAM_INT); return $stmt->execute(); } catch (\PDOException $e) { MySQL::instance()->showException($e); } } return false; }
public function removeUsersFromRole($roleId) { if (Role::instance($this->preferences, $this->db)->findById($roleId)) { try { $sql = "DELETE FROM rpd_user_has_role WHERE id_role = :idRole"; $stmt = $this->db->prepare($sql); $this->id = (int) $roleId; $stmt->bindParam(':idRole', $this->id, PDO::PARAM_INT); return $stmt->execute(); } catch (\PDOException $e) { MySQL::instance()->showException($e); } } return false; }