Using the Xataface API from the outside

A place for users and developers of the Xataface to discuss and receive support.

Using the Xataface API from the outside

Postby 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
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Re: Using the Xataface API from the outside

Postby 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'
    )
));
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Using the Xataface API from the outside

Postby 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
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Re: Using the Xataface API from the outside

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Using the Xataface API from the outside

Postby 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
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved