fixed db connection
This commit is contained in:
+19
-8
@@ -1,8 +1,19 @@
|
|||||||
<?php␍
|
<?php
|
||||||
$con = mysqli_connect('localhost', 'u00wiumd4xnrd', 'ukowysga7w5x', 'dbcov4clvrmrzn');␍
|
|
||||||
// Check connection␍
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
if (mysqli_connect_errno())␍
|
|
||||||
{␍
|
if (!isset($_ENV['DB_HOST'])) {
|
||||||
echo "Failed to connect to MySQL: " . mysqli_connect_error();␍
|
Dotenv\Dotenv::createImmutable(__DIR__ . '/../')->safeLoad();
|
||||||
}␍
|
}
|
||||||
?>
|
|
||||||
|
$con = mysqli_connect(
|
||||||
|
$_ENV['DB_HOST'] ?? 'localhost',
|
||||||
|
$_ENV['DB_USERNAME'] ?? '',
|
||||||
|
$_ENV['DB_PASSWORD'] ?? '',
|
||||||
|
$_ENV['DB_DATABASE'] ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check connection
|
||||||
|
if (mysqli_connect_errno()) {
|
||||||
|
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||||
|
}
|
||||||
|
|||||||
+19
-7
@@ -1,7 +1,19 @@
|
|||||||
<?php␍
|
<?php
|
||||||
//dependent dropdown in php Database Connection␍
|
//dependent dropdown in php Database Connection
|
||||||
$conn = new mysqli('localhost', 'u00wiumd4xnrd', 'ukowysga7w5x', 'dbcov4clvrmrzn');␍
|
|
||||||
if ($conn->connect_error) {␍
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
die("Connection failed: " . $conn->connect_error);␍
|
|
||||||
}␍
|
if (!isset($_ENV['DB_HOST'])) {
|
||||||
?>
|
Dotenv\Dotenv::createImmutable(__DIR__ . '/../')->safeLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = new mysqli(
|
||||||
|
$_ENV['DB_HOST'] ?? 'localhost',
|
||||||
|
$_ENV['DB_USERNAME'] ?? '',
|
||||||
|
$_ENV['DB_PASSWORD'] ?? '',
|
||||||
|
$_ENV['DB_DATABASE'] ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|||||||
+17
-80
@@ -1,19 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
if (!isset($_ENV['DB_HOST'])) {
|
||||||
|
Dotenv\Dotenv::createImmutable(__DIR__ . '/../../')->safeLoad();
|
||||||
|
}
|
||||||
|
|
||||||
Class Dropdown
|
Class Dropdown
|
||||||
{
|
{
|
||||||
|
private $host;
|
||||||
private $host = 'localhost';
|
private $username;
|
||||||
private $username = 'u00wiumd4xnrd';
|
private $password;
|
||||||
private $password = 'ukowysga7w5x';
|
private $dbname;
|
||||||
private $dbname = 'dbcov4clvrmrzn';
|
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
//establish connection
|
//establish connection
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$this->host = $_ENV['DB_HOST'] ?? 'localhost';
|
||||||
|
$this->username = $_ENV['DB_USERNAME'] ?? '';
|
||||||
|
$this->password = $_ENV['DB_PASSWORD'] ?? '';
|
||||||
|
$this->dbname = $_ENV['DB_DATABASE'] ?? '';
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
|
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
|
||||||
@@ -22,75 +30,4 @@ Class Dropdown
|
|||||||
{
|
{
|
||||||
echo "Connection error " . $e->getMessage();
|
echo "Connection error " . $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//fetch all country records from database
|
|
||||||
public function fetchCountry()
|
|
||||||
{
|
|
||||||
$data = null;
|
|
||||||
|
|
||||||
$query = "SELECT * FROM article_type ORDER BY article_type.name_articletype";
|
|
||||||
|
|
||||||
if ($sql = $this->connection->query($query))
|
|
||||||
{
|
|
||||||
while ($rows = mysqli_fetch_assoc($sql))
|
|
||||||
{
|
|
||||||
$data[] = $rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//fetch model records from database depend upon country id
|
|
||||||
public function fetchModel($idarticletype)
|
|
||||||
{
|
|
||||||
$data = null;
|
|
||||||
|
|
||||||
$query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' ";
|
|
||||||
|
|
||||||
if ($sql = $this->connection->query($query))
|
|
||||||
{
|
|
||||||
while ($rows = mysqli_fetch_assoc($sql))
|
|
||||||
{
|
|
||||||
$data[] = $rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//fetch Charact records from database depend on article type
|
|
||||||
public function fetchCharact($idarticletype)
|
|
||||||
{
|
|
||||||
$data = null;
|
|
||||||
|
|
||||||
$idarticletype = (int)$idarticletype;
|
|
||||||
|
|
||||||
$query = "
|
|
||||||
SELECT DISTINCT
|
|
||||||
ac.*
|
|
||||||
FROM article_characteristic ac
|
|
||||||
INNER JOIN standards s
|
|
||||||
ON s.idarticlecharacteristic = ac.idarticlecharacteristic
|
|
||||||
AND s.idarticletype = ac.idarticletype
|
|
||||||
WHERE ac.idarticletype = $idarticletype
|
|
||||||
AND s.active = 'Y'
|
|
||||||
ORDER BY ac.name_articlecharacteristic
|
|
||||||
";
|
|
||||||
|
|
||||||
if ($sql = $this->connection->query($query))
|
|
||||||
{
|
|
||||||
while ($rows = mysqli_fetch_assoc($sql))
|
|
||||||
{
|
|
||||||
$data[] = $rows;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
+40
-121
@@ -1,121 +1,40 @@
|
|||||||
␍
|
<?php
|
||||||
<?php␍
|
// Archivia in ZIP la cartella modulo_certificazione (backup)
|
||||||
// dump db and backup folder yogasoul... placed into claudiosironi.com ... folder of backup = tempzip in the main ideezeur folder␍
|
// NB: il vecchio blocco di dump database è stato rimosso perché conteneva
|
||||||
␍
|
// credenziali in chiaro ed era disattivato. Se serve un dump DB,
|
||||||
␍
|
// usare mysqldump o un comando artisan dedicato.
|
||||||
//dump database ␍
|
|
||||||
/*␍
|
ignore_user_abort(true);
|
||||||
ini_set('memory_limit', '-1');␍
|
set_time_limit(3600);
|
||||||
// Database configuration␍
|
|
||||||
$host = "localhost";␍
|
$main_path = '../modulo_certificazione';
|
||||||
$username = "u00wiumd4xnrd";␍
|
$zip_file = '../tempbck//cimac.tar';
|
||||||
$password = "ukowysga7w5x";␍
|
|
||||||
$database_name = "dbcov4clvrmrzn";␍
|
if (file_exists($main_path) && is_dir($main_path)) {
|
||||||
␍
|
$zip = new ZipArchive();
|
||||||
// Get connection object and set the charset␍
|
|
||||||
$conn = mysqli_connect($host, $username, $password, $database_name);␍
|
if (file_exists($zip_file)) {
|
||||||
$conn->set_charset("utf8");␍
|
unlink($zip_file); // truncate ZIP
|
||||||
␍
|
}
|
||||||
␍
|
if ($zip->open($zip_file, ZIPARCHIVE::CREATE) !== TRUE) {
|
||||||
// Get All Table Names From the Database␍
|
die("cannot open <$zip_file>\n");
|
||||||
$tables = array();␍
|
}
|
||||||
$sql = "SHOW TABLES";␍
|
|
||||||
$result = mysqli_query($conn, $sql);␍
|
$files = 0;
|
||||||
␍
|
$paths = array($main_path);
|
||||||
while ($row = mysqli_fetch_row($result)) {␍
|
|
||||||
$tables[] = $row[0];␍
|
while (list(, $path) = each($paths)) {
|
||||||
}␍
|
foreach (glob($path . '/*') as $p) {
|
||||||
?>␍
|
if (is_dir($p)) {
|
||||||
<?php␍
|
$paths[] = $p;
|
||||||
$sqlScript = "";␍
|
} else {
|
||||||
foreach ($tables as $table) {␍
|
$zip->addFile($p);
|
||||||
␍
|
$files++;
|
||||||
// Prepare SQLscript for creating table structure␍
|
echo $p . "<br>\n";
|
||||||
$query = "SHOW CREATE TABLE $table";␍
|
}
|
||||||
$result = mysqli_query($conn, $query);␍
|
}
|
||||||
$row = mysqli_fetch_row($result);␍
|
}
|
||||||
␍
|
|
||||||
$sqlScript .= "\n\n" . $row[1] . ";\n\n";␍
|
echo 'Total files: ' . $files;
|
||||||
␍
|
$zip->close();
|
||||||
␍
|
}
|
||||||
$query = "SELECT * FROM $table";␍
|
|
||||||
$result = mysqli_query($conn, $query);␍
|
|
||||||
␍
|
|
||||||
$columnCount = mysqli_num_fields($result);␍
|
|
||||||
␍
|
|
||||||
// Prepare SQLscript for dumping data for each table␍
|
|
||||||
for ($i = 0; $i < $columnCount; $i ++) {␍
|
|
||||||
while ($row = mysqli_fetch_row($result)) {␍
|
|
||||||
$sqlScript .= "INSERT INTO $table VALUES(";␍
|
|
||||||
for ($j = 0; $j < $columnCount; $j ++) {␍
|
|
||||||
$row[$j] = $row[$j];␍
|
|
||||||
␍
|
|
||||||
if (isset($row[$j])) {␍
|
|
||||||
$sqlScript .= '"' . $row[$j] . '"';␍
|
|
||||||
} else {␍
|
|
||||||
$sqlScript .= '""';␍
|
|
||||||
}␍
|
|
||||||
if ($j < ($columnCount - 1)) {␍
|
|
||||||
$sqlScript .= ',';␍
|
|
||||||
}␍
|
|
||||||
}␍
|
|
||||||
$sqlScript .= ");\n";␍
|
|
||||||
}␍
|
|
||||||
}␍
|
|
||||||
␍
|
|
||||||
$sqlScript .= "\n"; ␍
|
|
||||||
}␍
|
|
||||||
?>␍
|
|
||||||
<?php␍
|
|
||||||
if(!empty($sqlScript))␍
|
|
||||||
{␍
|
|
||||||
// Save the SQL script to a backup file␍
|
|
||||||
$backup_file_name = '../tempbck/'.$database_name . '_backup_.sql';␍
|
|
||||||
$fileHandler = fopen($backup_file_name, 'w+');␍
|
|
||||||
$number_of_lines = fwrite($fileHandler, $sqlScript);␍
|
|
||||||
fclose($fileHandler); ␍
|
|
||||||
} */␍
|
|
||||||
?>␍
|
|
||||||
␍
|
|
||||||
<? ␍
|
|
||||||
// archive into ZIP the folder␍
|
|
||||||
ignore_user_abort(true);␍
|
|
||||||
set_time_limit(3600);␍
|
|
||||||
␍
|
|
||||||
␍
|
|
||||||
$main_path = '../modulo_certificazione';␍
|
|
||||||
$zip_file = '../tempbck//cimac.tar';␍
|
|
||||||
␍
|
|
||||||
if (file_exists($main_path) && is_dir($main_path)) ␍
|
|
||||||
{␍
|
|
||||||
$zip = new ZipArchive();␍
|
|
||||||
␍
|
|
||||||
if (file_exists($zip_file)) {␍
|
|
||||||
unlink($zip_file); // truncate ZIP␍
|
|
||||||
}␍
|
|
||||||
if ($zip->open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) {␍
|
|
||||||
die("cannot open <$zip_file>\n");␍
|
|
||||||
}␍
|
|
||||||
␍
|
|
||||||
$files = 0;␍
|
|
||||||
$paths = array($main_path);␍
|
|
||||||
while (list(, $path) = each($paths))␍
|
|
||||||
{␍
|
|
||||||
foreach (glob($path.'/*') as $p)␍
|
|
||||||
{␍
|
|
||||||
if (is_dir($p)) {␍
|
|
||||||
$paths[] = $p;␍
|
|
||||||
} else {␍
|
|
||||||
$zip->addFile($p);␍
|
|
||||||
$files++;␍
|
|
||||||
␍
|
|
||||||
echo $p."<br>\n";␍
|
|
||||||
}␍
|
|
||||||
}␍
|
|
||||||
}␍
|
|
||||||
␍
|
|
||||||
echo 'Total files: '.$files;␍
|
|
||||||
␍
|
|
||||||
$zip->close();␍
|
|
||||||
} ␍
|
|
||||||
?>␍
|
|
||||||
|
|||||||
Reference in New Issue
Block a user