Using the Xataface API from the outside

Archived from the Xataface Users forum.

jay — Tue Sep 28, 2010 9:11 am

Hi all.

I setup a Xataface backoffice and some utilities to fill the database from external data, which is something that I’ll be doing frequently. I created a “/util” directory in which I’m placing these scripts to import external data, and I’d like to use the Xataface API from there. I tried using

Code: Select all
require_once '/my/path/to/xataface/dataface-public-api.php'

and

Code: Select all
df_init(__FILE__, '/xataface');

, but when I make a call to df_init, it dies with the message

Code: Select all
Error loading config file. No tables specified.

To sum up, this is my directory structure:
/index.php –> the entry point for Xataface
/xataface/ –> the Xataface directory
/util/ –> the utilities directory
/util/something.php –> I’m trying to use the Xataface API from here.

Is there something else I should do or this is not possible?

–jay


shannah — Tue Sep 28, 2010 9:42 am

At the bare minimum, Xataface needs a conf.ini file with at least one table specified. You can provide this in an associative array as a third parameter to df_init.

Code: Select all
df_init(__FILE__, 'dataface', array(     '_tables' => array(         'table1' => 'Table 1'     ) ));

jay — Wed Sep 29, 2010 9:04 am

That’s great, I simply read the ini with parse_ini_file and pass the ini object as the 3rd param.

I guess the framework won’t be able to find the ‘tables’ directory either so, is there a way I can configure the relationships between tables? Not that I need it right now actually, I’m just curious

Best,
–jay


shannah — Wed Sep 29, 2010 9:45 am

Actually, if this is in a different directory, you may be able to just get away with changing the first parameter to df_init().
The __FILE__ parameter points to a file within the site’s directory. If you replace this with an actual path to a file within your site (e.g. the conf.ini file) it should be able to find everything else.

-Steve


jay — Fri Oct 01, 2010 3:23 am

I tried that but I was passing the folder path! This way it actually works

Code: Select all
df_init("../../index.php", '/xataface');

Thanks a lot
–jay