admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * MySQLi Utility Class |
| 20 | * |
| 21 | * @category Database |
| 22 | * @author Rick Ellis |
| 23 | * @link http://www.codeigniter.com/user_guide/database/ |
| 24 | */ |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 25 | class CI_DB_mysqli_utility extends CI_DB_utility { |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 26 | |
| 27 | /** |
admin | 6ca6f94 | 2006-09-25 02:51:08 +0000 | [diff] [blame^] | 28 | * Create database |
| 29 | * |
| 30 | * @access public |
| 31 | * @param string the database name |
| 32 | * @return bool |
| 33 | */ |
| 34 | function create_database($name) |
| 35 | { |
| 36 | return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name)); |
| 37 | } |
| 38 | |
| 39 | // -------------------------------------------------------------------- |
| 40 | |
| 41 | /** |
| 42 | * Drop database |
| 43 | * |
| 44 | * @access public |
| 45 | * @param string the database name |
| 46 | * @return bool |
| 47 | */ |
| 48 | function drop_database($name) |
| 49 | { |
| 50 | return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name)); |
| 51 | } |
| 52 | |
| 53 | // -------------------------------------------------------------------- |
| 54 | |
| 55 | /** |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 56 | * Version number query string |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 57 | * |
| 58 | * @access public |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 59 | * @return string |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 60 | */ |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 61 | function _version() |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 62 | { |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 63 | return "SELECT version() AS ver"; |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | // -------------------------------------------------------------------- |
| 67 | |
admin | a5e812c | 2006-09-25 02:17:30 +0000 | [diff] [blame] | 68 | /** |
| 69 | * Show table query |
| 70 | * |
| 71 | * Generates a platform-specific query string so that the table names can be fetched |
| 72 | * |
| 73 | * @access public |
| 74 | * @return string |
| 75 | */ |
| 76 | function _show_tables() |
| 77 | { |
| 78 | return "SHOW TABLES FROM `".$this->db->database."`"; |
| 79 | } |
| 80 | |
| 81 | // -------------------------------------------------------------------- |
| 82 | |
| 83 | /** |
| 84 | * Show columnn query |
| 85 | * |
| 86 | * Generates a platform-specific query string so that the column names can be fetched |
| 87 | * |
| 88 | * @access public |
| 89 | * @param string the table name |
| 90 | * @return string |
| 91 | */ |
| 92 | function _show_columns($table = '') |
| 93 | { |
| 94 | return "SHOW COLUMNS FROM ".$this->db->_escape_table($table); |
| 95 | } |
| 96 | |
| 97 | // -------------------------------------------------------------------- |
| 98 | |
| 99 | /** |
| 100 | * Field data query |
| 101 | * |
| 102 | * Generates a platform-specific query so that the column data can be retrieved |
| 103 | * |
| 104 | * @access public |
| 105 | * @param string the table name |
| 106 | * @return object |
| 107 | */ |
| 108 | function _field_data($table) |
| 109 | { |
| 110 | $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1"; |
| 111 | $query = $this->db->query($sql); |
| 112 | return $query->field_data(); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | |
admin | 7b613c7 | 2006-09-24 18:05:17 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | ?> |