你好,我只想问一下我的项目中有3个表product,color和product_color。我使用insert_batch插入数据库,然后工作正常,当我使用update_batch更新product_color表时遇到一些问题,这是我的示例代码:
数据库:
product:id,name,sku...
color:id,color_name
product_color:id,pro_id,color_id
输入表单:
<?php foreach($colors as $color): ?>
<input type="checkbox" class="form-check-input" name="color[]" value="<?php echo $color->color_id; ?>" <?php foreach ($productcolor as $key => $value){ $array[] = $value->color_id;} if(in_array($color->color_id,$array)) echo 'checked'; else ''; ?>>
<label class="form-check-label">
<?php echo $color->color_name; ?>
</label>
<?php endforeach; ?>
实际上,我想从product_color表中传递主ID。在这里,我传递color_id。 这是我的控制器:
$colorBatch = array();
foreach ($color as $colorvalue) {
$colorBatch[] = array(
'id'=>$id
'pro_id' =>$pid,
'color_id' => $colorvalue
);
}
$this->db->update_batch('product_color', $colorBatch,'pro_id');
其中$ pid包含product_id;
是否可以通过输入表单传递product_color表的主ID或有更好的解决方案来解决此问题。对不起,英语不好。
谢谢
答案 0 :(得分:1)
请检查以下代码,因为您的数组结构不正确;
# Build the bigram and trigram models
bigram = gensim.models.Phrases(t_preprocess(dataset.data), min_count=5, threshold=100)
bigram_mod = gensim.models.phrases.Phraser(bigram)
def make_bigrams(texts):
return [bigram_mod[doc] for doc in texts]
data_words_bigrams = make_bigrams(t_preprocess(dataset.data))
# Create Dictionary
id2word = corpora.Dictionary(data_words_bigrams)
# Create Corpus
texts = data_words_bigrams
# Term Document Frequency
corpus = [id2word.doc2bow(text) for text in texts]
mallet_path='/home/riteshjain/anaconda3/mallet/mallet2.0.8/bin/mallet'
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path,corpus=corpus, num_topics=12, id2word=id2word, random_seed = 0)
coherence_model_ldamallet = CoherenceModel(model=ldamallet, texts=texts, dictionary=id2word, coherence='c_v')
a = "When Honda builds a hybrid, you've got to be sure it’s a marvel. And an Accord Hybrid is when technology surpasses the known and takes a leap of faith into tomorrow. This is the next generation Accord, the ninth generation to be precise."