Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
MongoDB
  • I'm new to MongoDB (and pretty new to Fuel as well) and I'm not sure that I'm accessing the database correctly as my code looks pretty wonky. Is there a better way to write the examples below? Here is my code for getting a single user with the given email address: $db = \Mongo_Db::instance();
    $result = $db->get_where('users', array('email' => $email), 1);
    $result = (array)$result;
    return $result[0]; And here is code to get just the unique id for that user... $result = $db->get_where('users', array('email' => $email), 1);
    $result = (array)$result;
    $id = (array)$result[0];
    return $id; The casting to array is because the first element in the object is 0 and I couldn't make $result->{0} work. The regular DB class has a current() method. Is there something similar for MongoDB? Thanks,
    Brad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!