Hirdetés
Ú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
- Samsung 75 QE75QN90A Neo QLED 4K UHD Smart TV Mini LED + Quantum Dot eladó
- ASUS ROG Zephyrus G16 (2024) RTX 4090 (!!) / Ultra 9 / GAR 2027 brutál erős, csúcs modell
- Cooler Master CK550 RGB mechanikus billentyűzet (Gateron Brown, HU)
- Elgato Stream Deck 15 gombos (MK.1) + állvány
- Gamer PC Ryzen 7 5800X + RTX 3060 12GB / 32GB RAM / vízhűtés / RGB
- Telefon felvásárlás!! iPhone 14/iPhone 14 Plus/iPhone 14 Pro/iPhone 14 Pro Max
- Samsung Galaxy Watch6 Classic 47mm LTE, Újszerű, 1 Év Garanciaval
- Gamer billentyűzetek /Akko/Monsgeek/Montech/Asus/SteelSeries/Ozone/Deltaco/DE/UK/Számlával!/
- Dell Latitude 5410 - 14" FHD touch, Core i5 10310U, 16GB RAM, SSD, jó akku, számla, 6 hó gar
- Asus TUF A15 FX506 - 15.6" Full HD 144Hz - Ryzen 5-4600H - 8GB - 512GB - Win11 - GTX 1650 Ti - HUN
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

