/** * Close database connection and print out debug data if present * @return void */ public function __destruct() { if ($this->connection) { $this->connection->close(); $this->connection = false; } }
/** * Explictly close the handle. Can not close the handle (mysqli_stmt) * before it has been prepared. * * @throws Appfuel\Framework\Exeception when handle is already closed * @throws \Exception when trying to close before prepared * @return bool */ public function close() { if ($this->isClosed()) { return true; } if ($this->driver instanceof mysqli_stmt) { $this->driver->close(); $this->driver = null; $this->isClosed = true; return true; } return false; }
/** * @return bool */ public function close() { $status = $this->getStatus(); if (!$this->isDriver()) { return true; } if (!$this->driver->close()) { $this->setError($driver->connect_errno, $driver->connect_error); $this->setStatus('connection closed failed'); return false; } $this->setStatus('closed'); $this->isConnected = false; $this->driver = null; return true; }
/** * generateDatabase * Execute TickiSql for application * @param string $dir The application's root directory. * @param \Composer\IO\IOInterface $io IO interface to write to console. * @return void */ public static function generateDatabase($rootDir, $io) { $installDatabase = $io->ask('Install Ticki database automatically ? </info> [<comment>Y,n</comment>]? ', 'Y', 'Y'); if ($installDatabase !== 'N' || $installDatabase !== 'n') { $TickiConfig = $rootDir . '/config/schema/Ticki.sql'; $content = file_get_contents($TickiConfig); $content = str_replace('_DATABASE_', static::$_databaseName, $content); $result = file_put_contents($TickiConfig, $content); if (!$result) { $io->write('Unable to update Database value on sql file.'); return; } $mysqli = null; if (static::$_port) { $mysqli = new Mysqli(static::$_hostName, static::$_userName, static::$_password, "", static::$_port); } else { $mysqli = new Mysqli(static::$_hostName, static::$_userName, static::$_password); } if ($mysqli->connect_errno) { $io->write("<error>Connection fail : " . $mysqli->connect_error . '</error>'); return; } if (!$mysqli->multi_query($content)) { $io->write('<error>Unable to install database, do it manually please</error>'); } $mysqli->close(); $io->write('<info>Set up database Ticki is a success.</info>'); } }
function getAmount() { $id = $_GET['id']; $type = $_GET['type']; $mysqli = new Mysqli(DBSERVER, DBUSER, DBPWD, DB); switch ($type) { case "cantine": case "repas": $query = "SELECT `montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_cantine` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { //$output = "&montantcfp=".$row['montantfcp']."&montanteuro=".$row['montanteuro']."&restearegler=".$row['restearegler']; $output = $row; } break; case "etal": $query = "SELECT `montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_etal` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { //$output = "&montantcfp=".$row['montantfcp']."&montanteuro=".$row['montanteuro']."&restearegler=".$row['restearegler']; $output = $row; } break; case "amarrage": $query = "SELECT `montantfcp`,`montanteuro`,`restearegler` FROM `" . DB . "`.`factures_amarrage` WHERE `idfacture` = {$id}"; $result = $mysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { //$output = "&montantcfp=".$row['montantfcp']."&montanteuro=".$row['montanteuro']."&restearegler=".$row['restearegler']; $output = $row; } break; } $mysqli->close(); return $output; }
/** * Close current connection. */ public function close() { $this->link->close(); }
if (!is_array($result)) { $error['type'] = "login"; $error['message'] = $result; } else { $_SESSION['user_session'] = $result['username']; $_SESSION['user_admin'] = $result['admin']; $_SESSION['user_supportpin'] = $result['supportpin']; $_SESSION['user_id'] = $result['id']; header("Location: index.php"); } break; case "register": $result = $user->add($_POST['username'], $_POST['password'], $_POST['confirmPassword']); if ($result !== true) { $error['type'] = "register"; $error['message'] = $result; } else { $username = $mysqli->real_escape_string(strip_tags($_POST['username'])); $_SESSION['user_session'] = $username; $_SESSION['user_supportpin'] = "Faça login novamente para ver o ID do Suporte."; header("Location: index.php"); } break; } } include "view/header.php"; include "view/home.php"; include "view/footer.php"; } $mysqli->close();
<?php $conn = new Mysqli($host, $usuario, $cont, $bdd); if ($_POST[Eliminar]) { $id = $_POST['id']; $q_delete = "delete from interes where id={$id}"; $resultado = $conn->query($q_delete); if (!$resultado) { echo '<div>No se puede eliminar el interes </div>'; } else { echo '<div>Interes borrado con exito </div>'; } } $conn->close(); ?> <?php echo '<center><h5 id="encabezado">INTERESES POR PERSONA</h5></center>'; echo '<table border="1" align="center">'; echo '<tr>'; echo '<th>' . 'Interes' . '</th>'; echo '</tr>'; for ($j = 0; $j < $num_rows; ++$j) { $result->data_seek($j); $row = $result->fetch_array(MYSQLI_ASSOC); echo '<tr>';