blob: 9c773b4b9233750bf6917b7ccb7f05fb5fee8fc8 [file] [log] [blame]
admin7b613c72006-09-24 18:05:17 +00001<?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 */
admina5e812c2006-09-25 02:17:30 +000025class CI_DB_mysqli_utility extends CI_DB_utility {
admin7b613c72006-09-24 18:05:17 +000026
27 /**
admin6ca6f942006-09-25 02:51:08 +000028 * 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 /**
admina5e812c2006-09-25 02:17:30 +000056 * Version number query string
admin7b613c72006-09-24 18:05:17 +000057 *
58 * @access public
admina5e812c2006-09-25 02:17:30 +000059 * @return string
admin7b613c72006-09-24 18:05:17 +000060 */
admina5e812c2006-09-25 02:17:30 +000061 function _version()
admin7b613c72006-09-24 18:05:17 +000062 {
admina5e812c2006-09-25 02:17:30 +000063 return "SELECT version() AS ver";
admin7b613c72006-09-24 18:05:17 +000064 }
65
66 // --------------------------------------------------------------------
67
admina5e812c2006-09-25 02:17:30 +000068 /**
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
admin7b613c72006-09-24 18:05:17 +0000117}
118
119?>