Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Flourish with YAF (yet another framework)

posted by chemdream 7 years ago

Hi! I'm having a strange problem when referencing fResult with Yaf.

In my bootstrap, I create the db object: try { $connection = new fDatabase(all my parms);

$connection->connect(); } catch (fAuthorizationException $e) { $e->printMessage(); }

Yaf_Registry::set('db', $connection);

When I need to run a query, I simply run:

$rs = Yaf_Registry::get('db')->query("select whatever");

That works, but I get warnings:

PHP Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result PHP Warning: mysqli_close(): Couldn't fetch mysqli

It seems to happen when I call $rs->fetchRow (or a similar method)

Any ideas on what is causing this?

p.s. other than that error, Yaf + Flourish creates an amazingly fast framework!!



I'm not particularly sure how YAF works, but from the comments on mysqli:

The cryptic "Couldn't fetch mysqli" error message can mean any number of things, including:

  1. You're trying to use a database object that you've already closed (as noted by ceo at l-i-e dot com). Reopen your database connection, or find the call to <?php mysqli_close($db); ?> or <?php $db->close(); ?> and remove it.
  2. Your MySQLi object has been serialized and unserialized for some reason. Define a wakeup function to re-create your database connection. http://php.net/__wakeup
  3. Something besides you closed your mysqli connection (in particular, see http://bugs.php.net/bug.php?id=33772)
  4. You mixed OOP and functional calls to the database object. (So, you have <?php $db->query() ?> in the same program as <?php mysqli_query($db) ?>).

My guess is that internally YAF is causing 1, 2, or 3 on that list. This is, of course, the unfortunate part of using a framework such as YAF. You're kinda stuck dealing with a bit of a black box unless you're well versed in C and want to try to track down how it actually does resource handling.

I assume, given that it's at such a low level it is partially responsible for resource allocation, de-allocation, garbage collection, etc. These could all be causing these types of issues.

posted by mattsah 7 years ago