Besides instantiating the object you need just two lines of code to get a result from the database in a variety of formats.
Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.
To obtain a new instance of the JDatabase Query class we use the JDatabase Driver get Query method: takes an optional argument, $new, which can be true or false (the default being false).
To query our data source we can call a number of JDatabase Query methods; these methods encapsulate the data source's query language (in most cases SQL), hiding query-specific syntax from the developer and increasing the portability of the developer's source code.
If you need plan to get the LAST_INSERT_ID() from a INSERT ... I haven't seen this mentioned elsewhere on this page, but you can use a SELECT statement as a single value if it returns a single value.You also get rid of the probably necessary table-lock during this action. ON DUPLICATE KEY UPDATE statement, the returned value is as follows:1 for each successful INSERT.2 for each successful UPDATE.For example, if you insert 5 rows with this syntax, and 3 of them were inserted while 2 were updated, the return value would be 7:((3 inserts * 1) (2 updates * 2)) = 7.download the script by clicking following link and try it in your projects.Feel free to comment your suggestions regarding this tutorial.