Using D/Xataface API, vs standard mysql_query statements

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

Using D/Xataface API, vs standard mysql_query statements

Postby mikewassil » Fri Feb 13, 2009 5:33 pm

In a post quite a few versions ago, Mon Apr 17, 2006 9:29 pm, you explained the possiblity of using D/Xataface API, vs standard mysql_query statements on the frontend applications. I'm interested in trying that and have a test underway. Unfortunately, I've run into a snag straight away.

Code: Select all
// initialize dataface framework
require_once '/path/to/dataface/dataface-public-api.php';
df_init(__FILE__, '/url/to/dataface');

$query = array();
$profiles =& df_get_records('Profiles', $query);
...
while ( $profiles->hasNext() ){
$profile =& $profiles->next();



I get the following error:

Fatal error: Call to a member function hasNext() on a non-object..

I've searched a bit with no luck finding anything to explain what is missing and causing this error. Much appreciate any suggestions. Thanks.

Michael
Mike Wassil
mikewassil
 
Posts: 36
Joined: Wed Dec 19, 2007 3:47 pm

Postby shannah » Sat Feb 14, 2009 6:57 am

Hi Michael,

This means that $profiles is likely null (meaning that the call to df_get_records()) didn't find anything.

An alternative, if you prefer to work with arrays (rather than iterators) is to use the df_get_records_array() function:

$profiles =& df_get_records_array('Profiles', $query);
if ( !$profiles ) {echo "No Profiles found!";exit;}
foreach ($profiles as $profile ){
...
}

.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 16 guests

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