How to convert PHP Logic to Views API I am writing a module to convert serialized value stored in database by the Composed Field Module. The serialized value is like:

a:3:{i:1;s:14:"First Subfield";i:2;s:15:"Second Subfield";i:3;s:14:"Third Subfield";}

The PHP Unserialize value of above serialized data returns the following array:

print_r(unserialize('a:3:{i:1;s:14:"First Subfield";i:2;s:15:"Second Subfield";i:3;s:14:"Third Subfield";}'));
Array
(
    [1] =&gt; First Subfield
    [2] =&gt; Second Subfield
    [3] =&gt; Third Subfield
)


I called the Module as composed_views

So far I have made few files like: composed_views.info, composed_views.module,

composed_views_handler_subfields.inc contains:

class composed_views_handler_subfields extends views_handler_field {
  /**
  * Render the unserialized value.
  */
  public function render($values, $index) {
    $uns = unserialize($values) // $values = serialized data from database
    return $this-&gt;get_value($uns[$index]); // $index = array index of serialized data
  }
}


In composed_views.views.inc  

For eg: The table names are field_one, field_two
The data column are field_one-composed, field_two-composed respectively


I want to Query those tables 
and send the serialized data to render function defined in composed_views_handler_subfields.inc file  


So, far the structure is like this:

function composed_views_views_data() {
  $data['composed_views_table'] = array();
  // The actual code I am seeking help with
  return $data;
  }


Any help how to do with this with views would be appreciated.
There is some discussion in several places about this, including an issue in the Composed Field issues queue. 

The module author writes;


  I haven't investigated the mechanics behind it but theoretically all that needs to be done is to somehow implements the process that those modules do on retrieving the field value from the database and then unserialize and concatenate the retrieved value.


The problem of course with storing serialised data is the inability to effectively query it using any type of relational db (No indexes.) 

You can always build a query using a LIKE on the serialised data ... 

WHERE field_one-composed LIKE '%query%'; 


But that's horrible. :( 

My comment on the initial question stands; do you want to achieve this using the GUI or through code? I'll update this answer based on your response.

While I appreciate this is not the question, I'm curious about why you chose this module for your use case?