Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @param array $data
  5. * @return int
  6. */
  7. public function insertSomeAndGetLastInsertValue(array $data)
  8. {
  9. $insert = $this->sql->insert();
  10. $insert->values($data);
  11. $stmt = $this->sql->prepareStatementForSqlObject($insert);
  12. $result = $stmt->execute(); // Zend\Db\Adapter\Driver\Pdo\Result
  13. if ($result->valid() && ($result instanceof \Zend\Db\Adapter\Driver\ResultInterface)) {
  14. return $result->getGeneratedValue();
  15. }
  16. return -1;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement