i'm trying to install class inside class, in static method
class db extends PDO
{
private static $error;
private static $sql;
private static $bind;
private static $errorCallbackFunction;
private static $errorMsgFormat;
private static $pdo;
public function __construct($dsn = "mysql:host=localhost;dbname=main;",
$user="root", $passwd="")
{
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
);
try {
self::$pdo = new PDO($dsn, $user, $passwd, $options);
} catch (PDOException $e) {
self::$error = $e->getMessage();
}
}
this is how i install a class inside the private static $pdo, i think it can be done, but when i calling
public static function run($sql, $bind="")
{
self::$sql = trim($sql);
self::$bind = self::cleanup($bind);
self::$error = "";
try {
$pdostmt = self::$pdo->prepare(self::$sql);
there is an error with the error message
Call to a member function prepare() on a non-object
isit possible to install class inside a static variable?thanks for helping.