- Fotók, videók mobillal
- Realme GT 2 Pro - papírforma
- iPhone topik
- Xiaomi 14T Pro - teljes a család?
- Merész dizájn és új teleobjektív az iPhone 17 Pro mobilokban
- Samsung Galaxy S23 Ultra - non plus ultra
- Beszélhetünk a Nothing Ear (3) tokjába is
- Telekom mobilszolgáltatások
- Okos (AI) szemüveget mutatott be a Meta
- Bemutatkozott a Poco X7 és X7 Pro
Ú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 Galaxy Z Fold 6 Silver Shadow Hajlítható csúcstechnológia, AI extrákkal 2028. 01.24 Gari
- AKCIÓ! DELL Precision 7540 i7-9850H Quadro T2000 16GB 512GB 1 év garancia
- Apple Pad 5.generácio / 32GB / Wi-fi / 12Hó garancia
- GYÖNYÖRŰ iPhone 15 Pro Max 256GB Black -1 ÉV GARANCIA - Kártyafüggetlen, MS3496, 90% Akkumulátor
- Dell USB-C dokkolók: (K20A) WD19/ WD19S/ WD19DC + 130W, 180W, 240W töltők
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest