Professional CodeIgniter, Thomas Myer

Chapter 7: Improving the Dashboard
196
Figure 7-3

If you have a spreadsheet tool (like Numbers on the Mac or the more ubiquitous Excel), you should be
able to open the CSV file and see results similar to Figure 7 - 4 .
Figure 7-4

Notice that you could go back and refine this export by sorting by certain fields, but at the end of the day
you have to ask yourself, " Why bother? " After all, you ' re exporting the data in a spreadsheet - friendly
way, so any further sorting and filtering can be done in the spreadsheet.


Creating an Export Function for Products

Creating the export function for Products is going to follow pretty much the same path you took with
Categories. In fact, it ' s very much exactly the same, except that your URLs will differ slightly, as will
your SQL query. As there aren ' t that many differences, there ' s no point belaboring the obvious.
Here ' s the
exportCsv()

function that gets added to the MProducts model:
function exportCsv(){
$this-
>
load-
>
dbutil();
$Q = $this-
>
db-
>
query("select * from products");
return $this-
>
dbutil-
>
csv_from_result($Q,",","\n");
}
c07.indd 196
c07.indd 196
6/10/08 5:36:39 PM
6/10/08 5:36:39 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.