Doubt with Bank column

0

I got a mysql dump to study and I was left in some text column with the fields filled in this way:

'a:5:{
    s:9:\"user_data\";
    s:0:\"\";
    s:4:\"nome\";
    s:5:\"admin\";
    s:2:\"id\";
    s:1:\"1\";
    s:9:\"permissao\";
    s:1:\"1\";
    s:6:\"logado\";
    b:1;
}'

The column in yes contained this name user_data . They could help me with this doubt of knowledge. Unfortunately I do not have the system code. In another table tbm contains a column as well but with name column permissions.

    
asked by anonymous 02.11.2015 / 01:36

1 answer

1

This data format is generated by serialize of php, it is used to convert php variables and a format that can be stored, mainly arrays .

When you do this:

<?php
$data = array(
   'nome' => 'Thalles',
   'hobby' => 'Programar'
);

echo serialize($data);

This string is generated:

  

a: 2: {s: 4: "name"; s: 7: "Thalles"; s: 5: "hobby"; s: 9:

Then you can store in a database or .txt and retrieve it later, however it will be necessary to use unserialize to decode, for example:

save.php

<?php
$data = array(
   'nome' => 'Thalles',
   'hobby' => 'Programar'
);

file_put_contents('data.txt', serialize($data));

ler.php

<?php
$data = unserialize(file_get_contents('data.txt'));//Trás de volta o array

print_r($data);

In this way you can store various data in a column only in your bank, wordpress uses this technique to facilitate the customized creation of plugins and banners.

    
02.11.2015 / 01:47