Tutorialsplane

Codeigniter DB Driver Reference


Codeigniter DB Driver Reference – This database reference has many class references. This is the platform-independent based DB implement class. This class will not be called directly. Or the adapter class for the specific database will extend and instantiate it. Here in this tutorial, we are going to explain how to use DB Driver Reference.


Codeigniter DB Driver Reference | Example

Let us understand how DB Driver Reference works in codeigniter with examples.

Class reference:-

There are following references available in DB Driver Reference. Now we will explain.

1. Initialize.

This reference is used to initialized database setting, established a connection to the database.

initialize()

2. DB connect.

This reference is used to establish a connection with the database.

db_connect($persistent = TRUE)

3. DB pconnect.

This reference is used to establish a persistent connection with the database.

db_pconnect()

4. Reconnect.

This reference is used to keep/reestablish the database connection.

reconnect()

5. DB select.

This reference is used to select/switch the current database.

db_select([$database = ''])

6. DB set charset.

This reference is used to set client character set.

db_set_charset($charset)

7. Platform.

This reference is used to display the name of platform.

platform()

8. Version.

This reference is used to display database number version.

version()

9. Query.

This reference is used to execute an SQL query.

query($sql[$binds = FALSE[$return_object = NULL]])

10. Simple query.

This reference is used to simplified version of the array method.

simple_query($sql)

11. Affected rows.

This reference is used to return the number of row changed by the last executed query.

affected_rows()

12. Trans strict.

This reference is used to enable/disable transaction “strict” mode.

trans_strict([$mode = TRUE])

13. Trans off.

This reference is used to disables transactions at run-time.

trans_off()

14. Trans start.

This reference is used to disables transactions at run-time.

trans_start([$test_mode = FALSE])

15. Trans complete.

This reference is used to complete the transaction.

trans_complete()

16. Trans status.

This reference is used to retrieve the transaction status flag.

trans_status()

17. compile binds.

This reference is used to compiles an SQL query with the bind values passed for it.

compile_binds($sql, $binds)

18. Is write type.

This reference is used to determines if a query is of a “write” type (INSERT, UPDATE, DELETE) or “read” type (SELECT).

is_write_type($sql)

19. Elapsed time.

This reference is used to calculate the aggregate query elapsed time.

elapsed_time([$decimals = 6])

20. Total queries.

This reference returns the total number of queries that have been executed.

total_queries()

21. Last query.

This reference returns the last query that was executed.

last_query()

22. Escape.

This reference is used to escapes input data based on type, including boolean and NULL.

escape($str)

23. Escape str.

This reference is used to escapes string values.

escape_str($str[$like = FALSE])

24. Escape like str.

This reference is used to escapes like string.

escape_like_str($str)

25. Primary.

This reference is used to retrieves the primary key of a table.

primary($table)

26. Count all.

This reference returns the total number of rows in a table.

count_all([$table = ''])

27. List tables.

This reference is used to get a list of the tables in the current database.

list_tables([$constrain_by_prefix = FALSE])

28. Table exists.

This reference is used to determine if a particular table exists.

table_exists($table_name)

29. List fields.

This reference is used to get a list of the field names in a table.

list_fields($table)

30. Field exists.

This reference is used to determine if a particular field exists.

field_exists($field_name, $table_name)

31. Field data.

This reference is used to get a list containing field data about a table.

field_data($table)

32. Escape identifiers.

This reference is used to escape SQL identifiers, such as column, table and names.

escape_identifiers($item)

33. Insert string.

This reference is used to generate an INSERT statement string.

insert_string($table, $data)

34. Update string.

This reference is used to generate an UPDATE statement string.

update_string($table, $data, $where)

35. Call function.

This reference is used to Runs a native PHP function , using a platform agnostic wrapper.

call_function($function)

36. Cache set path.

This reference is used to sets the directory path to use for caching storage.

cache_set_path([$path = ''])

37. Cache set path.

This reference is used to sets the directory path to use for caching storage.

cache_set_path([$path = ''])

38. Cache on.

This reference is used to disable database results caching.

cache_on()

39. Cache delete.

This reference is used to delete the cache files associated with a particular URI.

cache_delete([$segment_one = ''[$segment_two = '']])

40. Cache delete all.

This reference is used to delete all cache files.

cache_delete_all()

41. Close.

This reference is used to close the DB Connection.

close()

42. Display error.

This reference is used to display an error message and stop script execution.

display_error([$error = ''[$swap = ''[native = FALSE]]])

43. Protect identifiers.

This reference is used to takes a column or table name and applies the configured dbprefix to it.

protect_identifiers($item[$prefix_single = FALSE[$protect_identifiers = NULL[$field_exists = TRUE]]])

Models

Connect Database

Helpers

Libraries

Helper Reference

Library Reference

Database Reference