admin管理员组

文章数量:1134243

I am trying to count all birth years, months and days separately using get_results. I can also print them.

$wpdb->get_results("SELECT * FROM {$userـmeta} WHERE `meta_key` = 'birthday' ")

output:

                             Array
(
    [0] => stdClass Object
        (
            [umeta_id] => 134
            [user_id] => 1
            [meta_key] => birthday
            [meta_value] => a:3:{s:4:"year";s:4:"1920";s:5:"month";s:1:"6";s:3:"day";s:2:"16";}
        )

    [1] => stdClass Object
        (
            [umeta_id] => 172
            [user_id] => 4
            [meta_key] => birthday
            [meta_value] => a:3:{s:4:"year";s:4:"1952";s:5:"month";s:1:"3";s:3:"day";s:2:"14";}
        )

    [2] => stdClass Object
        (
            [umeta_id] => 279
            [user_id] => 8
            [meta_key] => birthday
            [meta_value] => a:3:{s:4:"year";s:4:"1999";s:5:"month";s:1:"4";s:3:"day";s:2:"13";}
        )

    [3] => stdClass Object
        (
            [umeta_id] => 284
            [user_id] => 5
            [meta_key] => birthday
            [meta_value] => a:3:{s:4:"year";s:4:"2015";s:5:"month";s:1:"3";s:3:"day";s:1:"9";}
        )

    [4] => stdClass Object
        (
            [umeta_id] => 289
            [user_id] => 6
            [meta_key] => birthday
            [meta_value] => a:3:{s:4:"year";s:4:"1945";s:5:"month";s:1:"2";s:3:"day";s:2:"17";}
        )

)

本文标签: count and echo json format wordpress database