PHP Extend generated model

Hi,
I’m trying to extend the generated model for my datatable to add a custom search function:

public static function findByEmail($email) {
$query = new BackendlessDataQuery();
$query->setWhereClause(“email_address=’” . $email. “’”);
$collection = Backendless::$Persistence->of( ‘clients’ )->find( $query );

    return $collection;
}

The class is being used in a custom event.

However, when the event is triggered, I get a "Fatal error: call to undefined method.

Any thoughts on why this isn’t being picked up? Or an alternative approach I can take?

Oh: and happy Christmas!

PS. In your forum category, you could do with adding a PHP option :slight_smile:

Regards,
Andy

Hi Andy,

Merry Christmas to you too!

I suspect the problem is somewhere with the paths when you import the class. An alternative (but less attractive) approach might be putting your utility function into the custom event class. Have you tried/considered that option?

Regards,
Mark

I did. Can’t remember the exact error, but again couldn’t find a reference to the data object or class. Do you have any sample code for using the generated classes in a custom event?

Regards
Andy

Hi Andy,

Sorry, I do not have such a sample. Are you saying that the custom event class cannot be found? Or the class containing the function you showed in the original post?

Mark