The structure of my mysql table is:
CREATE TABLE IF NOT EXISTS `tb_hour_counts` (
`date` date NOT NULL,
`subid` int(20) NOT NULL,
`unique_ids` int(20) NOT NULL,
`total_ids` int(20) NOT NULL,
`unique_ips` int(20) NOT NULL,
`total_ips` int(20) NOT NULL,
`global` int(20) NOT NULL,
`time` text NOT NULL,
UNIQUE KEY `ind_1` (`date`,`time`(5),`subid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I have an array of data like:
$array = array(
'0' => array(
'date' => '2011-10-10',
'time' => '00:00',
'subid' => '2',
'unique_ids' => '588'
),
'1' => array(
'date' => '2011-10-10',
'time' => '00:00',
'subid' => '2',
'unique_ips' => '3'
),
'2' => array(
'date' => '2011-10-10',
'time' => '00:00',
'subid' => '2',
'total_ids' => '3995'
),
'3' => array(
'date' => '2011-10-10',
'time' => '00:00',
'subid' => '2',
'total_ips' => '1000'
),
'4' => array(
'date' => '2011-10-10',
'time' => '00:00',
'subid' => '2',
'global' => '1000'
),
'5' => array(
'date' => '2011-10-10',
'time' => '01:00',
'subid' => '3',
'unique_ids' => '766'
),
'6' => array(
'date' => '2011-10-10',
'time' => '01:00',
'subid' => '3',
'unique_ips' => '10'
),
'7' => array(
'date' => '2011-10-10',
'time' => '01:00',
'subid' => '3',
'total_ids' => '934'
),
'8' => array(
'date' => '2011-10-10',
'time' => '01:00',
'subid' => '3',
'total_ips' => '950'
),
'9' => array(
'date' => '2011-10-10',
'time' => '01:00',
'subid' => '3',
'global' => '7554'
)
);
The goal is to insert the data into the table. The result of inserting the data from this array should be the following:

I believe this could be done either by mysql request, or by preparing the array for usual insert.
It’s very messy, but:
This gives you:
You can then just do something like: