Revize 7cee2250
Přidáno uživatelem horkym před téměř 7 roky(ů)
cron/db/db-pdo.php | ||
---|---|---|
9 | 9 |
protected $dbhost; |
10 | 10 |
protected $dbname; |
11 | 11 |
protected $dbh; |
12 |
|
|
13 |
protected $logs; |
|
12 | 14 |
|
13 | 15 |
public function __construct($user, $pass, $dbhost, $dbname) { |
14 | 16 |
$this->user = $user; |
... | ... | |
20 | 22 |
protected function connect() { |
21 | 23 |
$this->dbh = new PDO("mysql:host=".$this->dbhost.";dbname=".$this->dbname.";charset=utf8", $this->user, $this->pass); |
22 | 24 |
if (!$this->dbh) { |
23 |
throw new DB_Exception; |
|
25 |
throw new DB_Exception($this->logs);
|
|
24 | 26 |
} |
25 | 27 |
} |
26 | 28 |
|
... | ... | |
30 | 32 |
} |
31 | 33 |
$ret = $this->dbh->query($query); |
32 | 34 |
if (!$ret) { |
33 |
throw new DB_Exception; |
|
35 |
throw new DB_Exception($this->logs);
|
|
34 | 36 |
} else { |
35 |
$stmt = new DB_PDOStatement($this->dbh, $query); |
|
37 |
$stmt = new DB_PDOStatement($this->dbh, $query, $this->logs);
|
|
36 | 38 |
$stmt->result = $ret; |
37 | 39 |
$stmt->number = $ret->rowCount(); |
38 | 40 |
return $stmt; |
... | ... | |
47 | 49 |
public $query; |
48 | 50 |
public $number; |
49 | 51 |
protected $dbh; |
52 |
|
|
53 |
private $logs; |
|
50 | 54 |
|
51 |
public function __construct($dbh, $query) { |
|
55 |
public function __construct($dbh, $query, $logs) {
|
|
52 | 56 |
$this->query = $query; |
53 | 57 |
$this->dbh = $dbh; |
58 |
$this->logs = $logs; |
|
54 | 59 |
if (!$dbh) { |
55 |
throw new DB_Exception("Spojení s databází se nezdařilo!"); |
|
60 |
throw new DB_Exception($this->logs, "Spojení s databází se nezdařilo!");
|
|
56 | 61 |
} |
57 | 62 |
} |
58 | 63 |
|
59 | 64 |
public function fetchAssoc() { |
60 | 65 |
if (!$this->result) { |
61 |
throw new DB_Exception("Dotaz nebyl vykonán!"); |
|
66 |
throw new DB_Exception($this->logs, "Dotaz nebyl vykonán!");
|
|
62 | 67 |
} |
63 | 68 |
return $this->result->fetch(PDO::FETCH_ASSOC); |
64 | 69 |
} |
Také k dispozici: Unified diff
refs #6919: Logy
Oprava logovani v cronu. Do logu odchytavany i vyvolavane vyjimky. Pridan ukazkovy soubor (nejdrive beh OK, pote beh, kdy data uz byla v DB, pak beh, kdy data jeste nebyla ke stazeni, a na zaver beh, kdy byla spatna struktura DB).