dousi6405 2014-10-15 23:37
浏览 103

PHP - 如何扩展SQLite3Result类

This is what I came up with so far:

class SQLite3_extended extends SQLite3 {
  public function query($string){
    $result = parent::query($string);
    if(is_bool($result))
      return $result;
    else
      return new SQLite3Result_extended($this);
  } 
}

class SQLite3Result_extended extends SQLite3Result {
  public function test(){
    echo 'SQLite3Result extended successfully!';
  } 
}

And I get this: Fatal error: Call to private SQLite3Result::__construct() from context 'SQLite3_extended

HOW do I extend SQLite3Result class?

  • 写回答

1条回答 默认 最新

  • douyin7829 2014-10-16 00:14
    关注

    You can't. The SQLite3Result class can only be instantiated internally by SQLite3::query(); there is no way to construct an instance of this class, or of a subclass, yourself.

    If you want an extensible database class, use PDO. You can use a custom subclass for statements/results by calling PDO::setAttribute() with the PDO::ATTR_STATEMENT_CLASS argument. As a bonus, it may enable you to support database engines other than SQLite.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测