Smutty
MVC Framework
View Code: Smutty_Database_MySQL
Browse: All · Classes · Plugins
1
<?php
2
3
/**
4
* an implementation of the database class for MySQL
5
*
6
*/
7
8
class Smutty_Database_MySQL extends Smutty_Database {
9
10
/** the db connection */
11
var $cnn = null;
12
14
$cfg = Smutty_Config::getInstance();
15
$this->cnn = mysql_connect(
16
$cfg->get('db.host'),
17
$cfg->get('db.username'),
18
$cfg->get('db.password')
19
);
20
mysql_select_db( $cfg->get('db.name'), $this->cnn );
21
}
22
24
$res = mysql_query( $sql, $this->cnn );
25
return $res ? new Smutty_Database_MySQL_Result($res) : false;
26
}
27
29
return mysql_query($sql,$this->cnn) ? true : false;
30
}
31
33
$string = preg_replace( '/\\\\/', '\\\\\\\\', $string );
34
$string = preg_replace( '/\'/', '\\\'', $string );
35
return $string;
36
}
37
39
return mysql_insert_id( $this->cnn );
40
}
41
43
return mysql_error( $this->cnn );
44
}
45
47
return date( $this->getDateFormat() . ' h:i:s' );
48
}
49
51
return " desc `$table` ";
52
}
53
55
return 'Y-m-d';
56
}
57
59
$cfg = Smutty_Config::getInstance();
60
$user = $cfg->get( 'db.username' );
61
$pass = $cfg->get( 'db.password' );
62
$name = $cfg->get( 'db.name' );
63
system( "mysql -u \"$user\" " .
64
" --password=\"$pass\" " .
65
" -D \"$name\" " .
66
" -e \"source $file;\" " );
67
}
68
69
}
70
71
?>
The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.