Hirdetés
- Android alkalmazások - szoftver kibeszélő topik
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Yettel topik
- Jövő héten érkezik a Mate 80 széria
- Google Pixel topik
- Xiaomi 14 Ultra - Leica hercegnő
- Ezek a OnePlus 12 és 12R európai árai
- Samsung Galaxy A54 - türelemjáték
- Samsung Galaxy S23 Ultra - non plus ultra
- Az iPhone 17 gáncsolta el a Galaxy S26 Prót?
Ú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
- iPhone 13 PRO MAX 256GB sierra blue KÁRTYAFÜGGETLEN! Gyönyörű! Akkumlátor 89%!
- Vadonatúj, bontatlan iPhone AIR 256GB space black KÁRTYAFÜGGETLEN! 1 év Apple garancia!
- iPhone 16 128GB pink KÁRTYAFÜGGETLEN! Gyönyörű! Akkumlátor 94%!
- Eladó egy Pixel 7a
- Apple iMac 27" 5K ( 2019 ) Core i9 / 1TB SSD / 40GB / Sequoia
- GYÖNYÖRŰ iPhone 13 mini 128GB Midnight -1 ÉV GARANCIA - Kártyafüggetlen, MS3060, 100% Akkumulátor
- GYÖNYÖRŰ iPhone 12 mini 64GB White -1 ÉV GARANCIA - Kártyafüggetlen, MS3849, 100% Akksi
- Samsung Galaxy A25 5G 128GB, Kártyafüggetlen, 1 Év Garanciával
- Lenovo V130-15IGM laptop (Pentium Silver N5000/8GB/256GB SSD
- HP Omen 80G8E9 - 27" IPS - UHD 4K - 144Hz 1ms - NVIDIA G-Sync - FreeSync - HDR 400 - USB Type-C
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


