Casting - Dates, Blobs and Null

Casting - Dates, Blobs and Null

Casting - Dates, Blobs and Null --  DB_DataObject_Cast ::date(), ::blob(), ::sql()

Dealing with Casting, (everything except strings and numbers)

Warning

This is experimental!, although it is documented, it currently only supports a limited amount of databases (send me fixes if you want it to support your favorite database), and the internal operations/API may change in the future..

DataObjects is a very easy way to work with databases that are focused on numbers and strings. You can also use it on date fields (although you must format your strings correctly), and you can use it with other types by using raw SQL query(), and the string value "null" is automatically converted to NULL in the database.

In an effort to provide a cleaner way to code to the richer database types, the DB_DataObject_Cast object was created. It's purpose is to simply create an object to represent some of the more unusual types. Below is an example of using it to create a few simple types.

Cast Objects can be used in both building queries, and assigning values

As you can see, This component is in it"s infancy, so if you have any feature requests, ideas, please do not hesitate to contact me at alan_k at php dot net.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.