- OnePlus 15 - van plusz energia
- Google Pixel topik
- Milyen okostelefont vegyek?
- Samsung Galaxy S23 Ultra - non plus ultra
- Qualcomm lapkával és nagyobb teleppel várható a CMF Phone 3 Pro
- Honor Magic8 Pro - bevált recept kölcsönvett hozzávalókkal
- Samsung Galaxy A55 - új év, régi stratégia
- Apple Watch
- Poco X6 Pro - ötös alá
- Samsung Galaxy Watch4 és Watch4 Classic - próbawearzió
Ú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
- Apple iMac 27" 5K 2015 Late / 16GB DDR3 / 512 GB SSD / Bill+Egér 6 hó garancia, számlával!
- 27% GIGABYTE Z790 AORUS ELITE AX Alaplap bontatlan új !
- 350.000FT HELYETT! SzinteÚJ Ulefone Armor Pad 5 Ultra PROJEKTOROS KIB. KEMÉNY TABLET!!! 1.8kg
- Dell XPS 13 Plus 9320 i7-1260P 32GB 512GB 4K+ TouchScreen 1 év garancia
- Dell Latitude 5530 Core i5 1245U, 16GB RAM, SSD, jó akku, számla, 6 hó gar
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

