• hello guys, is it that wpdb::get_results parses all the attribute’s type to string?
    for example, I defined hits_count to be mediumint(9). When I use wpdb:get_results, it automatically parse this attribute from int to string.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Dion

    (@diondesigns)

    All MySQL database data is retrieved as strings. It is up to you to cast the results appropriately.

    Also be aware that using $wpdb->get_results() can cause memory/CPU issues. If you are retrieving multiple rows, you should consider setting up a loop and using $wpdb->get_row() to retrieve the results row-by-row.

    Thread Starter gaupoit

    (@gaupoit)

    Hi @prashant, I check carefully your link. However, I cannot see anywhere to mention to returned data automatically casting to string.

    Hi @dion, thanks for your information. Do you have any articles mentioning about the disadvantage of using $wpdb->get_results() as you mentioned?

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Results from wpdb::get_results’ is closed to new replies.