小编use*_*124的帖子

没有错误:没有调用PDO构造函数

下午好.我昨天开始使用PDO,我有一些问题.我正在创建extendet类,它不起作用,我找不到bug.

这是我的助手类的代码,对于工作女巫PDO:

    class EPDO extends PDO {
  /** Some identificator of connection*/
  public $db;

  /**
   * Creating new PDO connections
   */     
  public function __construct($dbhost, $dbname, $dbuser = 'root', $dbpass = '', $dbtype = 'mysql') {
    $db = new PDO($dbtype . ':host=' . $dbhost . ';dbname=' . $dbname, $dbuser, $dbpass);
  } 

  /**
   * Insert into database with using transaction (if operation failed the changes go before)
   */     
  public function insert($statement) {
    $db->beginTransaction();

    $status = $db->exec($statement);
    if ($status) {
      $db->commit();  
    } else …
Run Code Online (Sandbox Code Playgroud)

php pdo

0
推荐指数
1
解决办法
5828
查看次数

标签 统计

pdo ×1

php ×1