Start setting up the new editor in relevant pages.
Start setting up the new editor in relevant pages.

File last commit:

c3da001f5ff1
d5660b942da0
Show More
mysql.php
48 lines | 1.0 KiB | text/x-php | PhpLexer
<?php
class MysqlStore {
var $link;
function connect($server, $user, $pass, $dbname) {
$this->link = @mysqli_connect($server, $user, $pass, $dbname)
or mtdie('Could not connect to the database server.');
if( !$this->link ) mtdie('Could not connect to the database server.');
}
function query($sql, $showerror = true ) {
$r = mysqli_query( $this->link, $sql );
if( false === $r && $showerror ) echo mysqli_error($this->link);
return $r;
}
function getAll($sql) {
if( $r = $this->query( $sql ) ) {
$ret = array();
while( $row = mysqli_fetch_object( $r ) ) {
$ret[] = $row;
}
return $ret;
}
}
function getRow($sql) {
if( $r = $this->query( $sql ) ) {
if( false === $r ) {
echo mysqli_error($this->link);
return false;
}
if( mysqli_num_rows( $r ) == 0 ) return false;
return mysqli_fetch_object( $r );
}
}
function getOne($sql) {
if( $r = $this->query( $sql ) ) {
if( mysqli_num_rows( $r ) == 0 ) return false;
$ret = mysqli_fetch_row( $r );
return $ret[0];
}
}
}
?>