From 910d8620519d777ab45bdad5fb6dc9f05c6b2869 Mon Sep 17 00:00:00 2001
From: admin
Date: Tue, 26 Sep 2006 02:09:05 +0000
Subject:
---
system/database/DB_export.php | 38 +++++++++++++++++++++++++++++++++++---
system/database/DB_utility.php | 2 ++
user_guide/database/helpers.html | 9 ++++++++-
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/system/database/DB_export.php b/system/database/DB_export.php
index 195510d9d..1e94c6c97 100644
--- a/system/database/DB_export.php
+++ b/system/database/DB_export.php
@@ -23,19 +23,51 @@
* @link http://www.codeigniter.com/user_guide/database/
*/
class CI_DB_export {
-
+
+
+ function CI_DB_export()
+ {
+ log_message('debug', "Database Export Class Initialized");
+ }
+
/**
- * Some function
+ * Generate CVS
*
* @access public
* @return integer
*/
- function something()
+ function generate_cvs($query, $delim = "\t", $newline = "\n")
{
+ if ( ! is_object($query) OR ! method_exists($query, 'field_names'))
+ {
+ show_error('You must submit a valid result object');
+ }
+
+ $out = '';
+ foreach ($query->field_names() as $name)
+ {
+ $out .= $name.$delim;
+ }
+
+ $out .= $newline;
+
+ foreach ($query->result_array() as $row)
+ {
+ foreach ($row as $item)
+ {
+ $out .= $item.$delim;
+ }
+
+ $out .= $newline;
+ }
+
+
+ return $out;
}
// --------------------------------------------------------------------
+
}
?>
\ No newline at end of file
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index f98448adf..41941ae35 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -31,6 +31,8 @@ class CI_DB_utility {
// Assign the main database object to $this->db
$obj =& get_instance();
$this->db =& $obj->db;
+
+ log_message('debug', "Database Utility Class Initialized");
}
// --------------------------------------------------------------------
diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html
index 1d1fb37ad..8302fe6ee 100644
--- a/user_guide/database/helpers.html
+++ b/user_guide/database/helpers.html
@@ -76,6 +76,14 @@ Query Helpers
correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.
+$this->db->count_all();
+Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:
+echo $this->db->count_all('my_table');
+
+// Produces an integer, like 25
+
+
+
$this->db->platform()
Outputs the database platform you are running (MySQL, MS SQL, Postgre, etc...):
echo $this->db->platform();
@@ -86,7 +94,6 @@ correct number of affected rows. By default this hack is enabled but it can be
echo $this->db->version();
-
$this->db->last_query();
Returns the last query that was run (the query string, not the result). Example:
--
cgit v1.2.3-24-g4f1b