Welcome Guest, Not a member yet? Register   Sign In
Database Date & Time Format
#11

(02-09-2016, 03:30 AM)EpicKris Wrote: Using `$this->db->platform()` seems like the best idea, but given different drivers (such as MSSQL), prefer different formats, it seems like this should be part of the database library?

In most cases, the database library doesn't have any metadata for the fields you are working with, unless you request that data (and it usually just returns that data to you). In other words, the database library doesn't even know you're working with a date, and has no concept of what format is required for the various date formats supported by each platform.

Even when using Query Builder, the database library in CI is a relatively low-level library with a limited set of features and relatively low overhead.

Another option to consider would be to build a library in the manner of DB_Forge or DB_Utility, both of which load a driver based on which database platform is currently configured, but neither of which are loaded directly by the DB class (the way DB_Query_Builder is). This means that you could extend the loader to add another method, using the dbutil() and dbforge() methods as a reference, build an abstract class as the base for the library, then add the platform-specific drivers you need. So, it would be possible to add any number of features to the database library without having to modify the CI code directly.
Reply


Messages In This Thread
Database Date & Time Format - by EpicKris - 02-01-2016, 02:11 PM
RE: Database Date & Time Format - by donpwinston - 02-01-2016, 02:59 PM
RE: Database Date & Time Format - by EpicKris - 02-01-2016, 03:03 PM
RE: Database Date & Time Format - by donpwinston - 02-01-2016, 07:54 PM
RE: Database Date & Time Format - by EpicKris - 02-04-2016, 05:14 AM
RE: Database Date & Time Format - by Diederik - 02-04-2016, 08:42 AM
RE: Database Date & Time Format - by EpicKris - 02-04-2016, 12:16 PM
RE: Database Date & Time Format - by Narf - 02-04-2016, 04:05 PM
RE: Database Date & Time Format - by mwhitney - 02-08-2016, 10:06 AM
RE: Database Date & Time Format - by EpicKris - 02-09-2016, 03:30 AM
RE: Database Date & Time Format - by mwhitney - 02-09-2016, 07:16 AM
RE: Database Date & Time Format - by EpicKris - 02-09-2016, 12:26 PM
RE: Database Date & Time Format - by Narf - 02-09-2016, 01:04 PM
RE: Database Date & Time Format - by EpicKris - 02-09-2016, 01:32 PM
RE: Database Date & Time Format - by mwhitney - 02-09-2016, 02:19 PM
RE: Database Date & Time Format - by Narf - 02-09-2016, 03:11 PM
RE: Database Date & Time Format - by mwhitney - 02-11-2016, 01:59 PM
RE: Database Date & Time Format - by EpicKris - 02-11-2016, 02:10 PM
RE: Database Date & Time Format - by mwhitney - 02-12-2016, 02:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB