fetching an Integer from DB using Zend Framework returns the value as a string

后端 未结 4 1966
温柔的废话
温柔的废话 2021-02-20 07:42

When I run an sql query using the ZF wrappers, all the numeric values return as strings. What do I need to change so the values will return in the same data type as they are in

4条回答
  •  情话喂你
    2021-02-20 08:15

    For an example of using a custom Zend_Db_Table_Row to get correct data types, as Bill Karwin suggested, have a look at the class here: http://www.zfsnippets.com/snippets/view/id/70

    It can be implemented in your model as:

    class YourTableName extends Zend_Db_Table_Abstract
    {
        protected $_name = 'your_table_name';
        protected $_rowClass = 'Model_Row_Abstract';
    }
    

    You may want to change Model_Row_Abstract's datatype for tinyint to bool if you use it strictly to hold boolean values.

提交回复
热议问题