
//Edit: Ok, to hlavní bych vyřešil, ale teď je tu malá sviňárna (alespoň pro mě)
Spoiler: zobrazit
Ale v té spodní části, jak je připojení k MySQL, mi to vždy hodí undefined na všechny ty proměný s údaji od MySQL

Kód: Vybrat vše
<?php
class Database {
private db;
__construct($host, $user, $pw, $db) {
$this->db = new MySQLi($host, $user, $pw, $db);
$this->db->set_charset('UTF8');
}
public function command($sql) {
return $this->db->query($slq);
}
}
/* Použití */
...
$db = new Database('localhost', 'root', 'password', 'test');
$result = $db->command('SELECT * FROM test.tabulka;');
var_dump($result);
...
Kód: Vybrat vše
<?php
namespace App;
use Nette, Model, Nette/Database/Connection, Nette/Caching/Cache;
class Database extends Nette/Object {
private $db;
private $sf;
private $cache;
private $itemsPerPage;
public function __construct(Nette/Database/Connection $db, $itemsPerPage, $cache) {
$this->db = $db;
$this->sf = new Nette/Database/SelectionFactory($db);
$this->cache = $cache;
$this->itemsPerPage = $itemsPerPage;
}
public function getServers($sort = 'passivePoints', $order = 'DESC', $page = 1, $search = null, $filterString = null, $filterNumber = null) {
$args = array();
if (!empty($filterString)) $args['version_string'] = $filterString;
if (!empty($filterNumber)) $args['version_number'] = $filterNumber;
$args['sl_servers_live.status'] = 'Online';
return $this->sf->table('sl_servers_live')
->select('*')
->where($args)
->where('sl_servers_live.name LIKE ? OR
sl_servers.full_ip LIKE ? OR
sl_servers_live.version_string LIKE ? OR
sl_servers_live.version_number LIKE ? OR
sl_servers_live.map LIKE ?', "%$search%", "%$search%", "%$search%", "%$search%", "%$search%")
->order($sort . ' ' . $order)
->page($page, $this->itemsPerPage)
->fetchAll();
}
public function getServersCount($search = null, $filterString = null, $filterNumber = null) {
...
}
...
Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 5 hostů