1

I have followed the API tutorial. http://docs.phalconphp.com/en/latest/reference/tutorial-rest.html

I have everything working.

Now I am creating an authentication function that I will call at the beginning of each api call.

Example:

$app->get('/api/robots', function() use ($app) { $authdata=isauthorized($app); ... ..

So now in the "index.php" file I have a function titled "is_authorized"

The function runs fine, however I cannot execute SQL within this function.

The following example does not execute within the is_authorized function.

$phql = "SELECT * FROM Members ORDER BY id"; $robots = $app->modelsManager->executeQuery($phql);

While the above will run within my initial api call function it does not run in the is_authorized function. Is there a way to pass "$app" to this function so that I can use it to execute queries?

Gene Kelly
  • 189
  • 9

1 Answers1

1

This issue was unrelated to Phalcon and more of a issue with my understanding of how to pass by reference in PHP 5.4.

See this post for the reason on why I was running into the issue.

PHP 5.4 Call-time pass-by-reference - Easy fix available?

Community
  • 1
  • 1
Gene Kelly
  • 189
  • 9