Hello i want to automatically add an id to the inserted row on my table in Mysql db.
The table has no uniquie key and no AUTO_INCREASMENT. I just want a function to add the id automatically when the row is inserted.
This is the statement i have
$db = getDB();
if(isset($cId))
{
$cId = $request->post('cId');
}
else
{
$cId = '3';**//Here i want to put a new id **
}
$insert = array(
'c_id' => $cId,
'user_one' => $uid,
'user_two' => $recieverId,
'ip' => $_SERVER['REMOTE_ADDR'],
'time' => date('Y-m-d H:i:s'),
);
$sql = "INSERT INTO conversation (c_id,user_one, user_two, ip, time) VALUES (?,?,?,?,?)";
$stmt = $db->prepare($sql);
$stmt->execute(array_values($insert));
$request->post('cId'); is returned as wanted