Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: How to get an ID of a (inserted/updated/deleted) record using Query Builder? #48

Closed
AleksMeshkov opened this issue Oct 9, 2013 · 3 comments

Comments

@AleksMeshkov
Copy link

Could you please help me?

DB::connection('mongodb')->collection('apiRequests')->insert($entry);

How to get that record ID?

PS: DB::getPdo()->lastInsertId(); doesn't works :(

@jenssegers
Copy link
Contributor

Laravel has a insertGetId method that returns the id.

@yefriddavid
Copy link

In laravel is this in the model of Eloquent (->getKey())

@yefriddavid
Copy link

namespace App\Models\MongoDB\Cases;
use Jenssegers\Mongodb\Model as Eloquent;

class MyModel extends Eloquent {
protected $collection = 'xxxtableMongo';
protected $connection = 'mongodb';
}

in controller

$myModel->save()
$myModel->getKey();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants