Új hozzászólás Aktív témák
-
papa019
senior tag
válasz
fordfairlane
#10160
üzenetére
Igen, ez egy minták alapján alakítgatott kód. Próbálok egy használható alkalmazást összerakni és tudom, hogy ez egy hozzáértő számára gányolt kód.
A $DB változóhoz tartozó kód:
$config = array();
$config['host'] = '127.0.0.1';
$config['user'] = 'root';
$config['pass'] = '';
$config['table'] = 'onlab';
class DB
{
/**
* @desc Creates the MySQLi object for usage.
*
* @param $db required connection params.
*/
public function __construct($db) {
$this->mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['table']);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
}
/**
* @desc Simple preparation to clean the SQL/Setup Result Object.
*
* @param SQL statement
* @return
*/
public function Query($SQL)
{
$this->SQL = $this->mysqli->real_escape_string($SQL);
$this->Result = $this->mysqli->query($SQL);
if ($this->Result == true)
return true;
else
die('Problem with Query: ' . $this->SQL);
}
/**
* @desc Get the results
*
* @param $field Select a single field, or leave blank to select all.
* @return
*/
public function Get($field = NULL)
{
if ($field == NULL)
{
$data = array();
while ($row = $this->Result->fetch_array(MYSQLI_BOTH))
{
$data[] = $row;
}
}
else
{
$row = $this->Result->fetch_array(MYSQLI_BOTH);
$data = $row[$field];
}
/** Make sure to close the Result Set */
$this->Result->close();
return $data;
}
/**
* @desc Automatically close the connection when finished with this object.
*/
public function __destruct()
{
$this->mysqli->close();
}
}
$DB = new DB($config);
Új hozzászólás Aktív témák
- Xiaomi 17 Ultra - jó az optikája
- Milyen billentyűzetet vegyek?
- Honor Magic8 Pro - bevált recept kölcsönvett hozzávalókkal
- Kodi és kiegészítői magyar nyelvű online tartalmakhoz (Linux, Windows)
- Kerékpárosok, bringások ide!
- Assetto Corsa EVO
- Samsung Galaxy S26 Ultra - fontossági sorrend
- Apple MacBook
- Fűnyíró topik
- Starlink
- További aktív témák...
- Asus Dual Radeon RX 6500 XT 4GB
- BESZÁMÍTÁS! Asus Rog Strix Z390-F Gaming alaplap garanciával hibátlan működéssel
- BESZÁMÍTÁS! 4TB WD RED WD40EFAX HDD meghajtó garanciával hibátlan működéssel
- BESZÁMÍTÁS! MSI B650 R7 8700F 64GB DDR5 1TB SSD RX 7800 XT 16GB Montech XR TG FSP 750W
- BESZÁMÍTÁS! ASUS H610M i5 12400F 16GB DDR4 1TB SSD RTX 3050 6GB Endorfy Signum 300 TG MSI 650W
- ÁRGARANCIA!Épített KomPhone Ryzen 7 9800X3D 64GB RAM RTX 5080 16GB GAMER PC termékbeszámítással
- 27% - Corsair Premium Individually Sleeved TÁPEGYSÉG KÁBEL Pro Kit Type 4 Gen4
- Telefon felvásárlás!! Apple iPhone SE (2016), Apple iPhone SE2 (2020), Apple iPhone SE3 (2022)
- iPhone 13 Pro 128GB 100% (1év Garancia) - ÚJ EREDETI AKKUMULÁTOR
- 226 - Lenovo LOQ (15IRX10) - Intel Core i7-13650HX, RTX 5060
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
