добрый день, создаю выборку из бд в массив и записываю его в текстовый файл
$tables = array(1 => 'loadprice_categories', 2 => 'loadprice_schema', 3 => 'loadprice_pricing');
foreach ($tables as $key => $table) {
$table = DB_PREFIX.$table;
$query = $this->db->query("SELECT * FROM `" . $table . "` where supplier_id='".$supplier_id."'")->rows;
$content = array();
foreach ($query as $data) {
$content[$table] = $data;
$filename="data.txt";
$str_value = serialize($content);
$f = fopen($filename, 'a+');
fwrite($f, $str_value);
fclose($f);
}
}
в файл все записывается нормально, образец записи
a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1900";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"3";s:9:"xml_field";s:150:"<? $out = strtr('{#tire~brand#}',array("BFGoodrich"=>"BF Goodrich", "Nokian Tyres"=>"NOKIAN")); ?>";s:8:"xml_attr";s:0:"";s:10:"base_field";s:22:"manufacturer > name";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1899";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"2";s:9:"xml_field";s:4:"tire";s:8:"xml_attr";s:5:"stock";s:10:"base_field";s:21:"product > quantity";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1898";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"2";s:9:"xml_field";s:4:"tire";s:8:"xml_attr";s:5:"price";s:10:"base_field";s:18:"product > price";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1897";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"2";s:9:"xml_field";s:4:"tire";s:8:"xml_attr";s:5:"title";s:10:"base_field";s:29:"product_description > name";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1896";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"2";s:9:"xml_field";s:4:"tire";s:8:"xml_attr";s:3:"sku";s:10:"base_field";s:16:"product > sku";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1895";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"2";s:9:"xml_field";s:4:"tire";s:8:"xml_attr";s:3:"sku";s:10:"base_field";s:18:"product > model";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1894";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:1:"1";s:8:"xml_attr";s:0:"";s:10:"base_field";s:11:"#xml_optype";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1893";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:1:"1";s:8:"xml_attr";s:0:"";s:10:"base_field";s:12:"#xml_phptype";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1892";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:1:"1";s:8:"xml_attr";s:0:"";s:10:"base_field";s:13:"#excel_optype";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1891";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:0:"";s:8:"xml_attr";s:0:"";s:10:"base_field";s:13:"#excel_cfield";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1890";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:0:"";s:8:"xml_attr";s:0:"";s:10:"base_field";s:13:"#excel_ufield";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1889";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:0:"";s:8:"xml_attr";s:0:"";s:10:"base_field";s:15:"#excel_last_row";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1888";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:0:"";s:8:"xml_attr";s:0:"";s:10:"base_field";s:16:"#excel_first_row";s:10:"sort_order";s:1:"0";}}a:1:{s:19:"oc_loadprice_schema";a:7:{s:9:"schema_id";s:4:"1887";s:11:"supplier_id";s:1:"3";s:8:"xml_type";s:1:"1";s:9:"xml_field";s:0:"";s:8:"xml_attr";s:0:"";s:10:"base_field";s:12:"#excel_sheet";s:10:"sort_order";s:1:"0";}}
пытаюсь получить массив из файла
$file = file_get_contents($filename);
print_r(unserialize($file));
получаю только одну запись
Array
(
[oc_loadprice_schema] => Array
(
[schema_id] => 1900
[supplier_id] => 3
[xml_type] => 3
[xml_field] => <? $out = strtr('{#tire~brand#}',array("BFGoodrich"=>"BF Goodrich", "Nokian Tyres"=>"NOKIAN")); ?>
[xml_attr] =>
[base_field] => manufacturer > name
[sort_order] => 0
)
)
как получить весь массив из файла ?
и еще такой момент, сейчас если посмотреть то массив формируется вот так
Array
(
[oc_loadprice_schema] => Array
(
[schema_id] => 1900
[supplier_id] => 3
[xml_type] => 3
[xml_field] => <? $out = strtr('{#tire~brand#}',array("BFGoodrich"=>"BF Goodrich", "Nokian Tyres"=>"NOKIAN")); ?>
[xml_attr] =>
[base_field] => manufacturer > name
[sort_order] => 0
)
)
Array
(
[oc_loadprice_schema] => Array
(
[schema_id] => 1899
[supplier_id] => 3
[xml_type] => 2
[xml_field] => tire
[xml_attr] => stock
[base_field] => product > quantity
[sort_order] => 0
)
)
Array
(
[oc_loadprice_schema] => Array
(
[schema_id] => 1898
[supplier_id] => 3
[xml_type] => 2
[xml_field] => tire
[xml_attr] => price
[base_field] => product > price
[sort_order] => 0
)
)
а хотелось бы что бы вот так
Array
(
[oc_loadprice_schema] => Array
(
[schema_id] => 1900
[supplier_id] => 3
[xml_type] => 3
[xml_field] => <? $out = strtr('{#tire~brand#}',array("BFGoodrich"=>"BF Goodrich", "Nokian Tyres"=>"NOKIAN")); ?>
[xml_attr] =>
[base_field] => manufacturer > name
[sort_order] => 0
)
[oc_loadprice_schema] => Array
(
[schema_id] => 1899
[supplier_id] => 3
[xml_type] => 2
[xml_field] => tire
[xml_attr] => stock
[base_field] => product > quantity
[sort_order] => 0
)
[oc_loadprice_schema] => Array
(
[schema_id] => 1898
[supplier_id] => 3
[xml_type] => 2
[xml_field] => tire
[xml_attr] => price
[base_field] => product > price
[sort_order] => 0
)
спасибо