Código PHP:
<?php
class Inlinecms {
public $DBOR;
public $autoid;
public $type;
public $id;
public $name;
public $value;
public $date;
public $status;
public $lang;
public function __construct() {
try {
$instance = new PDO("mysql:localhost;dbname=db63542_dev", "root", "ushuai222");
$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo $e->getMessage();
}
$this->DBOR = $instance;
}
public function setCmsinline() {
try {
$query = "INSERT INTO cmsinline (
type,
id,
name,
value,
date,
status,
lang
) VALUES (
'".addslashes($this->type)."',
'".addslashes($this->id)."',
'".addslashes($this->name)."',
'".addslashes($this->value)."',
now(),
0,
'".addslashes($this->lang)."'
)";
$this->DBOR->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, false);
$sth = $this->DBOR->prepare($query);
$sth->execute();
$this->autoid = $this->DBOR->lastInsertId();
} catch(PDOException $e) {
echo $e->getMessage();
}
return $this->autoid;
}
public function getCmsinlineByType() {
$return = array();
$query = "SELECT * FROM cmsinline WHERE type = '".$this->type."' AND status = 0 AND lang = '".$this->lang."'";
$sth = $this->DBOR->prepare($query);
$sth->execute();
while ($result = $sth->fetch(PDO::FETCH_OBJ))
$return[$result->id][$result->name] = $result;
return $return;
}
public function getNextId() {
$query = "SELECT max(id) as id FROM cmsinline WHERE status = 0";
$sth = $this->DBOR->prepare($query);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_OBJ);
return ($result->id + 1);
}
public function updateCmsinline() {
try {
$query = "UPDATE cmsinline SET value = '".addslashes($this->value)."', date=now() WHERE id='".addslashes($this->id)."' AND type='".addslashes($this->type)."' AND name='".addslashes($this->name)."' AND status='0' ";
$sth = $this->DBOR->prepare($query);
$sth->execute();
} catch(PDOException $e) {
echo $e->getMessage();
}
}
public function deleteCmsinline() {
try {
$query = "UPDATE cmsinline SET status = '".addslashes($this->status)."', date=now() WHERE id='".addslashes($this->id)."'";
$sth = $this->DBOR->prepare($query);
$sth->execute();
} catch(PDOException $e) {
echo $e->getMessage();
}
}
}
?>
Código HTML:
could not find driver Fatal error: Call to a member function prepare() on a non-object in C:\AppServ\www\vinamar\inlinecms.class.php on line 57