dongweizhen2009 2013-06-19 14:49
浏览 84
已采纳

error:在非对象上调用成员函数startTrans()

I am using pOWL to build a content management system of OWL files. I want to be able to query the OWL files as well as add new instances and classes. However I am stuck. I need to load the OWL file into an OWLModel using pOWL. So I tried:

$base="wine.owl";
$store = new DefaultPOWLStore(ADODB_DB_DRIVER, "localhost", "powl", "root", "password");

$model = ModelFactory::getOntModel('DBModel','RDFS_VOCABULARY', $base);
$model = new OWLModel($store, $base);
$model->load('wine.owl');

$model -> __construct($store, $base);

But I am getting the error:

Fatal error: Call to a member function startTrans() on a non-object in C:\Users\xxx\xxx\powldfapi-php\api\model\DbModel.php on line 878

The code with the error is:

    if (is_a($model, 'MemModel')) {
            if (is_object($model)){
            echo "<pre>";
            print_r("!!!!!!!");
            echo "</pre>";
        }

        $this->dbConn->startTrans();

I added the second if clause in an attempt to check if $model is an object, and it passed the clause. But I am not sure if that is the correct way to check if a variable is an object.

UPDATE: The issue seems to be with dbConn variable, need to find a way to load the model into the DB for dbConn to be defined. Will look tomorrow.

  • 写回答

1条回答 默认 最新

  • doutou1922 2013-06-20 14:26
    关注

    got around this as I was trying to load the OWL file into the model. I should have loaded the file using$store. Here is the code:

    $modelURI = "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#";
    $base="wine.owl";
    $filename ="wine.owl";
    $store = new DefaultPOWLStore(ADODB_DB_DRIVER, "localhost", "powl", "root", "password");
    
    if(!$store->modelExists($modelURI)) {
        $store->loadModel($modelURI, $base);
    }
    
    $model = new OWLModel($store, $modelURI);
    $store-> putModel($store, $modelURI);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作