Sunday, July 31, 2011
Thursday, July 28, 2011
Saturday, July 16, 2011
codeIgniter database methods
The database class provides a wrapper of most common functions used for database access, and also others which simplify common queries. All queries performed with the database through the database abstraction layer can be analyzed for the execution time and further optimization.
Example:
$query=$db->query("SELECT * FROM Table [WHERE Field='Value']");
while($result=$db->fetch_array($query))
{
$data1=$result['FieldName1'];
$data2=$result['FieldName2'];
(etc.)
}
Contents
- 1 Available Methods
- 1.1 Commonly Used
- 1.2 Others
- 1.2.1 $db->connect
- 1.2.2 $db->select_db
- 1.2.3 $db->explain_query
- 1.2.4 $db->data_seek
- 1.2.5 $db->close
- 1.2.6 $db->errno
- 1.2.7 $db->error
- 1.2.8 $db->dberror
- 1.2.9 $db->affected_rows
- 1.2.10 $db->num_fields
- 1.2.11 $db->list_tables
- 1.2.12 $db->table_exists
- 1.2.13 $db->field_exists
- 1.2.14 $db->shutdown_query
- 1.2.15 $db->select_query
- 1.2.16 $db->get_version
- 1.2.17 $db->optimize_table
- 1.2.18 $db->analyze_table
- 1.2.19 $db->show_create_table
- 1.2.20 $db->show_fields_from
- 1.2.21 $db->is_fulltext
- 1.2.22 $db->supports_fulltext
- 1.2.23 $db->supports_fulltext_boolean
- 1.2.24 $db->create_fulltext_index
- 1.2.25 $db->drop_index
[edit] Available Methods
[edit] Commonly Used
[edit] $db->query
Executes an SQL query with your database.[edit] $db->simple_select
See Simple Select.[edit] $db->fetch_array
Returns an array of values for the first row (can be iterated through with a while statement)Example:
$query=$db->query("SELECT * FROM Table [WHERE Field='Value']");
while($result=$db->fetch_array($query))
{
$data1=$result['FieldName1'];
$data2=$result['FieldName2'];
(etc.)
}
[edit] $db->fetch_field
See Fetch_Field.[edit] $db->num_rows
Returns the number of rows in the query[edit] $db->insert_id
Returns the insert id (The id of the primary key) of the insert query just run[edit] $db->insert_query
Runs an insert query on a table in a database. Receive two parameters:- string - The table name to perform the query on.
- array - An array of fields and their values.
[edit] $db->update_query
Runs an update query on a table in a database[edit] $db->delete_query
Used to perform a delete query on a table in a database[edit] $db->escape_string
Replaces addslashes, escapes data before being used in a query[edit] Others
[edit] $db->connect
Connects a new database.[edit] $db->select_db
Selects the database for the current MySQL Session[edit] $db->explain_query
Helps to explain queries run from on database from the current session for debugging purposes.[edit] $db->data_seek
Moves the internal pointer to the specified column[edit] $db->close
Closes the connection to the currently open database[edit] $db->errno
Returns the error number (if any) of the specified query resource[edit] $db->error
Returns the error string (if any) of the specified query resource[edit] $db->dberror
Outputs an error message (if any) of the specified query resource[edit] $db->affected_rows
Returns the amount of affected rows from a "write" query[edit] $db->num_fields
Returns the number of fields of the specified query resource[edit] $db->list_tables
Returns the tables in the current open database[edit] $db->table_exists
Returns true if the specified table exists[edit] $db->field_exists
Returns true if the specified field exists[edit] $db->shutdown_query
Runs a query thats performed when php is done parsing the file[edit] $db->select_query
Runs a complex query (join queries). (Note: Depreciated in MyBB 1.4)[edit] $db->get_version
Returns the version number of the database server being used[edit] $db->optimize_table
Runs an optimize query on a table[edit] $db->analyze_table
Runs an analyze query on a table[edit] $db->show_create_table
Return the "create table" command for a specific table.[edit] $db->show_fields_from
Show the "show fields from" command for a specific table.[edit] $db->is_fulltext
Returns whether or not the table contains a fulltext index.[edit] $db->supports_fulltext
Returns whether or not this database engine supports fulltext indexing.[edit] $db->supports_fulltext_boolean
Returns whether or not this database engine supports boolean fulltext matching.[edit] $db->create_fulltext_index
Creates a fulltext index on the specified column in the specified table with optional index name.[edit] $db->drop_index
Drop an index with the specified name from the specified tableFriday, July 15, 2011
Thursday, July 14, 2011
Wednesday, July 13, 2011
Subscribe to:
Comments (Atom)
Bind Some Event to Element and trigger that function when click the element
Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...
-
Find highcharts which are loaded in the page and then convert chart into png using jquery Charts are loaded through the ajax See the e...