semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

Problem with function fetchRow() ARC2_Store.php on line 761 #130

Open excel007 opened 5 years ago

excel007 commented 5 years ago

Hello

I setup new arc2 with on a PHP server Version 5.6.31. I follow from https://github.com/semsol/arc2. But when I coding these php code :

<?php

include_once(dirname(__FILE__).'/arc/ARC2.php'); // path to the file ARC2.php
include_once(dirname(__FILE__).'/config.php');

$store = ARC2::getStore($arc_config);
$store->query('LOAD <http://chatlogs.planetrdf.com/swig/2009-07-26>');

?>

I have a problem. It shows message

( ! ) Fatal error: Call to a member function fetchRow() on null in ...\arc\store\ARC2_Store.php on line 761

Please help me for this error. Thank you


EDIT by @k00ni: Fix code highlighting

k00ni commented 5 years ago

Hi @excel007, sorry for the late answer.

It seems internal variables are not initialized properly is the problem. Its not your fault, our documentation is missing this. Please try the following code:

<?php 

include_once(dirname(__FILE__).'/arc/ARC2.php'); // path to the file ARC2.php
include_once(dirname(__FILE__).'/config.php');

$store = ARC2::getStore($arc_config);

// NEW
$store->createDBCon(); // <== creates DB connection
$store->setup(); // <== checks if required tables are exist

$store->query('LOAD <http://chatlogs.planetrdf.com/swig/2009-07-26>');

If you installed ARC2 without composer you might have to include further files to get ARC2 running. The old "way" with including the ARC2 file is not valid anymore, since 2.4, unfortunately. I forgot to adapt the ARC2 to include all required files (#106). That is an unsolved issue.

Please respond how it went.

excel007 commented 5 years ago

Thank you :)

It can be load into MySQL.

Hi @excel007, sorry for the late answer.

It seems internal variables are not initialized properly is the problem. Its not your fault, our documentation is missing this. Please try the following code:

<?php 

include_once(dirname(__FILE__).'/arc/ARC2.php'); // path to the file ARC2.php
include_once(dirname(__FILE__).'/config.php');

$store = ARC2::getStore($arc_config);

// NEW
$store->createDBCon(); // <== creates DB connection
$store->setup(); // <== checks if required tables are exist

$store->query('LOAD <http://chatlogs.planetrdf.com/swig/2009-07-26>');

If you installed ARC2 without composer you might have to include further files to get ARC2 running. The old "way" with including the ARC2 file is not valid anymore, since 2.4, unfortunately. I forgot to adapt the ARC2 to include all required files (#106). That is an unsolved issue.

Please respond how it went.

fishfree commented 3 years ago

The same problem existes in the latest version: v2.5.1, please reopen this issue.

k00ni commented 3 years ago

@fishfree can you post a simple script which shows the problem?