How to get last inserted id when using custom query

how to get last inserted id when using custom query in cakephp3?