| 
                         我对数据库的PDO查询将不必要的值返回到数组中. 
Array
(
    [contentID] => 9
    [0] => 9
    [type] => operations
    [1] => operations
    [type_alts] => pages
    [2] => pages
    [url] => ctt-partners
    [3] => ctt-partners
    [title] => CTT Partners
    [4] => CTT Partners
    [subtitle] => 
    [5] => 
    [online] => 1
    [6] => 1
    [access] => 0
    [7] => 0
    [req] => 0
    [8] => 0
 
) 
我在数组之后没有返回相同的整数字段以及名称.例如[0] => 9,[1] =>操作.我也不想要这些. 
他们为什么在这里,我怎么能摆脱他们. 
谢谢, 
最佳答案
您当前的获取类型必须是:
PDO::FETCH_BOTH (default): returns an array indexed by both column name and 0-indexed column number as returned in your result set  
 
鉴于您的要求,它应该是: 
PDO::FETCH_ASSOC: returns an array indexed by column name as returned in your result set  
 
fetch_style 
Controls how the next row will be returned to the caller. This value must be one of the PDO::FETCH_* constants,defaulting to value of PDO::ATTR_DEFAULT_FETCH_MODE (which defaults to PDO::FETCH_BOTH).  
 
Reference:                         (编辑:莱芜站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |