-1
다음 항목을 쿼리 할 때 쉼표를 추가하는 방법은 무엇입니까? 질문에 자세한 내용을 추가하십시오.다음 항목을 쿼리 할 때 쉼표를 추가하는 방법은 무엇입니까?
// Indented the codes to make it more readable
$participants = [602, 600];
$query = array();
$query[] = 'INSERT INTO ' .
$db->nameQuote('#__social_conversations_participants');
$query[] = '(' . $db->nameQuote('conversation_id') .',' .
$db->nameQuote('user_id') . ',' . $db->nameQuote('state') . ')';
$query[] = 'VALUES';
foreach($participants as $userId){
$query[] = '(' . $db->Quote($conversationId) . ',' .
$db->Quote($userId) . ',' . $db->Quote(1) . ')';
//이 경우에는() 다음은 항상 여기에서 거짓
// Indented the codes to make it more readable
if(next($participants) !== false){
$query[] = ',';
}
}
// Glue query back.
$query = implode(' ' , $query);
var_dump($query);exit;
넣어 노력을 너의 질문. – Darren
어떤 데이터베이스 라이브러리입니까? 매개 변수가있는 쿼리가 있습니까? – Isaac
왜 이런 식으로 쿼리를 작성합니까? 배열에 다시 들어가서 왜 다시 연결해야합니까? –