MyBB Community Forums

Full Version: Multiple insert
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,
I'm trying to insert multiple templates in the database but my code didn't work. Have I used wrong function?

$templates = [
        'forum_display_thread_icon_custom' => '<img src="{$ticon}" alt="" style="max-width: {$mybb->settings[\'ticon_width\']}px; max-height: {$mybb->settings[\'ticon_height\']}px">',
        'posticons_custom' => '<tr>
    <td class="trow1">
        <strong>{$lang->ticon_custom}</strong>
    </td>
    <td class="trow1">
        <input class="fileupload" name="ticon" type="file">
    </td>
</tr>',
    ];
    
    foreach($templates as $name => $content) {
        $insert_array[] = [
            'title' => $name,
            'template' => $db->escape_string($content),
            'sid' => '-2',
            'version' => '1807',
            'dateline' => time(),
        ];
    }
    $db->insert_query_multiple('templates', $insert_array);
Hi, there's nothing there inserting the actual templates. All you're doing is building an array of the templates to add. You need to call "$db->insert_query_multiple()".
I updated post

ok now it works, I don't know why not before