简体   繁体   English

如何从WordPress数据库的BLOB列中检索数值数据

[英]How to retrieve numerical data from BLOB column in WordPress database

I have gone through to many discussions on BLOB but most of them are related to retrieving images from BLOB column but my requirement is to retrieve single data out of several binaries stored in the BLOB column. 我已经对BLOB进行了很多讨论,但是大多数讨论都与从BLOB列中检索图像有关,但是我的要求是从存储在BLOB列中的几个二进制文件中检索单个数据。

<?php $blobdata = $wpdb->get_results( "SELECT * FROM slips WHERE status = 'awaiting' " );

       foreach ( $blobdata as $bd ){
           $view = $bd->bet_options_ids; echo $view; 
        }
         endforeach;
        ?>

The above code prints as: a:1:{i:5;s:4:"1.45";} 上面的代码打印为:a:1:{i:5; s:4:“ 1.45”;}

Here I want to store the value of i:5 (i = 5) in variable say $store_i = $bd->bet_options_ids; 在这里,我想将i:5(i = 5)的值存储在变量$ store_i = $ bd-> bet_options_ids中;

I have no idea how can I get that individual data to store in variable or even just print out individually. 我不知道如何才能将单个数据存储在变量中,甚至只是单独打印出来。

Anyone's suggestions will be really helpful. 任何人的建议都会很有帮助。

$blobdata = $wpdb->get_results( "SELECT * FROM slips WHERE status = 'awaiting' " );

foreach ( $blobdata as $bd ){
 $view = $bd->bet_options_ids; //getting serialize data 
 $view = unserialize($view); // doing unserialize
 if(array_key_exists(5,$view)){ //checking array key is 5 or not
    $value = 5; //taking the value of 5 key element
  }
 }
echo $value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM