# id eingefügten Datensatzes, Shopware()-&gt;Db()-&gt;query($sql)

**URL:** <https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251>\
**Category:** Shopware 3.5\
**Tags:** general\
**Created:** [23. Februar 2015 um 11:09 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251 "2015-02-23T11:09:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [23. Februar 2015 um 11:09 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/1 "2015-02-23T11:09:45Z")

</div>

Liebes Forum, 🙂 🙂 ich habe eine Tabelle user\_tab, die eine id mit auto increment besitzt. Wenn ich nun einen Datensatz hinzufüge, zum Beispiel `$sql = "INSERT INTO `user_tab` (`id`, `username`,`sport`) VALUES (NULL, 1,'Karen','Tennis')"; Shopware()-\>Db()-\>query($sql);` dann kann ich die id durch `$id = Shopware()-\>Db()-\>lastInsertId();` herausfinden. Ist bei dieser Methode sichergestellt, dass keine andere session dazwischenfunkt? Es könnte ja sein, dass gleichzeitig ein anderer user auch seine Werte einträgt. Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![Thomas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomas/32/8167_2.png) [@Thomas](https://forum.shopware.com/u/Thomas)\
**Post date:** [23. Februar 2015 um 21:50 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/2 "2015-02-23T21:50:31Z")

</div>

Ja das ist sichergestellt. Gruß

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [23. Februar 2015 um 23:03 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/3 "2015-02-23T23:03:40Z")

</div>

Fein, fein, danke. Ist das auch irgendwo dokumentiert. Gibt es überhaupt eine Dokumentation der Shopware()-\>Db() Methoden? Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [23. Februar 2015 um 23:13 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/4 "2015-02-23T23:13:21Z")

</div>

Siehe [http://framework.zend.com/manual/1.12/d … apter.html](http://framework.zend.com/manual/1.12/de/zend.db.adapter.html) Viele Grüße

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [23. Februar 2015 um 23:56 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/5 "2015-02-23T23:56:33Z")

</div>

cool, vielen Dank. Und Shopware()-\>Db() entspricht dann dem einfachen Db() von Zend ? Bist du jetzt richtig offiziell Forummoderator? Warst du doch früher nicht, oder? Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![Thomas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/thomas/32/8167_2.png) [@Thomas](https://forum.shopware.com/u/Thomas)\
**Post date:** [24. Februar 2015 um 08:00 UTC](https://forum.shopware.com/t/id-eingefugten-datensatzes-shopware-gt-db-gt-query-sql/25251/6 "2015-02-24T08:00:50Z")

</div>

[quote=“Kerstin83”]Und Shopware()-\>Db() entspricht dann dem einfachen Db() von Zend ?[/quote] Shopware()-\>Db() ist eine Instanz von Enlight\_Components\_Db\_Adapter\_Pdo\_Mysql diese wiederum erweitert die Klasse Zend\_Db\_Adapter\_Pdo\_Mysql. Bis auf ein paar Kleinigkeiten ist das ein Instanz von Zend DB. Gruß
