type mb_intval exp name MySQL init escape_string exp tmpIDs array Quer

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$type = mb_intval($exp[1]);
$name = MySQL::init()->escape_string($exp[0]);
$tmpIDs = array();
$Query = MySQL::init('client',__LINE__,__FILE__)->query_assoc("SELECT `id` FROM `%PRE%ref_other` WHERE `type` = '{$type}' AND `name` = '{$name}' LIMIT 1");
if($Query)
$tmpIDs[$i] = array($Query['id'], $type);
else
{
MySQL::init('client',__LINE__,__FILE__)->query_unbuf("INSERT INTO `%PRE%ref_other` (`id`,`type`,`name`) VALUES (NULL, '{$type}', '{$name}')");
$tmpIDs[$i] = array(MySQL::init('client')->last_id, $type);
}
$tmpIDs = recursive_unique($tmpIDs);
foreach($tmpIDs as $value)
{
MySQL::init('client',__LINE__,__FILE__)->query_unbuf("INSERT INTO `%PRE%servers_additional_data` (`id`,`id_server`,`type`,`id_element`) ".
"VALUES (NULL, '{$id_server}', '{$value[1]}', '{$value[0]}')");
}