Counting the number of returned results with num_rows()
Counting the number of returned results with count_all_results()
Counting the number of returned results
Query binding
Finding the last insert ID
Finding the number of affected rows
Finding the last database query
Using CodeIgniter database migrations
Moving to the current version with current()
Rolling back/stepping forward with version()
Generating an XML from a database result
Generating a CSV from a database result
Introduction
Pretty much any application you build will require database access and a functionality, from basic Create, Read, Update, and Delete (CRUD) operations to more sophisticated approaches. In this chapter, we'll look at some fairly simple recipes (for example, simple CRUD operations), and then some more capable recipes such as connecting to multiple databases, database caching, and generating files as output.
Some recipes are quite simple, so I won't provide all the files for you to copy (in some cases, it may be unnecessary); instead, many of the recipes are small blocks of code that you can drop into real-world scenarios as you need to.