Changeset 655
- Timestamp:
- 10/04/2007 10:54:25 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
application/controllers/welcome.php (modified) (1 diff)
-
system/libraries/Database.php (modified) (1 diff)
-
system/libraries/drivers/Database_Mysql.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/controllers/welcome.php
r650 r655 81 81 foreach($query as $item) 82 82 { 83 print_r($item);83 //echo '<pre>'.print_r($item, true).'</pre>'; 84 84 } 85 85 86 die;87 86 echo '<pre>'.print_r($this->db->list_tables(), true).'</pre>'; 87 echo $this->db->table_exists('pages'); 88 88 print "Numrows: ".$query->num_rows()."<br/>"; 89 89 print "<pre>".print_r($this->database, TRUE)."</pre><br/>"; -
trunk/system/libraries/Database.php
r654 r655 693 693 $this->where = array(); 694 694 } 695 696 /** 697 * Returns an array of table names 698 * 699 * @access public 700 * @return array 701 */ 702 public function list_tables() 703 { 704 if (!$this->connected) $this->driver->connect($this->config); 705 706 return $this->driver->list_tables(); 707 } 708 709 /** 710 * Determine if a particular table exists 711 * @access public 712 * @return boolean 713 */ 714 public function table_exists($table_name) 715 { 716 return ( ! in_array($table_name, $this->list_tables())) ? FALSE : TRUE; 717 } 718 695 719 696 720 } // End Database Class -
trunk/system/libraries/drivers/Database_Mysql.php
r644 r655 300 300 return mysql_real_escape_string($str, $this->link); 301 301 } 302 303 /** 304 * List table query 305 * 306 * Generates a platform-specific query string so that the table names can be fetched 307 * 308 * @access private 309 * @return string 310 */ 311 public function list_tables() 312 { 313 $sql = "SHOW TABLES FROM `".$this->db_config['connection']['database']."`"; 314 $query = $this->query($sql); 315 $query = $query->result(); 316 317 $retval = array(); 318 foreach($query as $row) 319 { 320 $column = 'Tables_in_'.$this->db_config['connection']['database']; 321 $retval[] = $row->$column; 322 } 323 324 return $retval; 325 } 302 326 303 327 } // End Database_Mysql Class
