1
<?php
2
3
class PHPIO_Hook_Mysql extends PHPIO_Hook_Func {
4
const classname = 'Mysql';
5
var $hooks = array(
6
//'mysql_affected_rows',
7
'mysql_connect',
8
'mysql_create_db',
9
'mysql_db_query',
10
'mysql_drop_db',
11
'mysql_get_host_info',
12
'mysql_get_proto_info',
13
'mysql_get_server_info',
14
'mysql_info',
15
'mysql_insert_id',
16
'mysql_list_dbs',
17
'mysql_list_fields',
18
'mysql_list_processes',
19
'mysql_list_tables',
20
'mysql_pconnect',
21
'mysql_ping',
22
'mysql_query',
23
'mysql_select_db',
24
'mysql_set_charset',
25
'mysql_stat',
26
'mysql_thread_id',
27
'mysql_unbuffered_query',
28
);
29
30
function mysql_insert_id_post($jp) {
31
$this->trace['cmd'] = 'SELECT LAST_INSERT_ID()';
32
$this->postCallback($jp);
33
}
34
35
function mysql_pconnect_post($jp) {
36
$this->mysql_connect_post($jp);
37
}
38
39
function mysql_connect_post($jp) {
40
$this->link = $this->getLink($this->args);
41
$this->postCallback($jp);
42
}
43
44
function getLink($args) {
45
$link = $args[0];
46
if ( strpos($link, ':') === false ) {
47
$link .= ':3306';
48
}
49
return $link;
50
}
51
52
function postCallback($jp) {
53
$this->trace['link'] = $this->link;
54
55
if ( $this->result === false ) {
56
$this->trace['errno'] = mysql_errno();
57
$this->trace['error'] = mysql_error();
58
}
59
60
parent::postCallback($jp);
61
}
62
63
function mysql_query_post($jp) {
64
if ( is_resource($this->result) || $this->result === true ) {
65
$this->trace['rowcount'] = mysql_affected_rows();
66
}
67
68
$this->postCallback($jp);
69
}
70
}
71