0
我想將一個數組($array
)插入Mysql表(notification
),我試過但沒有輸入。我該如何解決這個問題?如何將數組插入到Mysql表中
$select = "SELECT * FROM addclique WHERE adder_id = :session_id";
$param1 = array ('session_id' => $_SESSION['id']);
$cliques = $db->query($select, $param1);
foreach($cliques as $key)
{
$array[] = $key['clique_id'];
}
$array[] = $key['clique_id'];
$notijfy = new Notification();
$notijfy->addCircle($array);
function addCircle($id_involve){
$escaped_values = array_map('mysql_real_escape_string', array_values($array));
$sql2 = "INSERT INTO notification(id_involve) VALUES (:id_involve)";
$param2 = array ('id_involve' => implode(", ", $escaped_values));
$result2 = $this->db->query ($sql2, $param2);
}
的http:// stackoverfl ow.com/questions/13507496/pdo-php-insert-into-db-from-an-associative-array – 2014-09-19 23:28:56