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

后端 未结 4 1864
温柔的废话
温柔的废话 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:16

    Databases typically return result sets as text. Unless your db adaptor converts things for you (and to sounds like yours does not), all values will come back as strings--dates, enums, etc. as well as integers.

    If you are dealing with a small number of tables with only a few integer fields, just hand convert them. If you are dealing with a slightly more complex situation, you could iterate through the columns using the database definitions (see sqlite_fetch_column_types(), etc.). If your situation is more complex than seems reasonable for these solutions, consider switching to a more featureful framework.

提交回复
热议问题