At finde seneste autoincrement

Kanbanens logfil skal gemme nummeret på sidste autoincrement i en anden tabel. Men hvordan finder man det? Løsning (inspired by this blogpost):

        // looking for the number of the last id increment
        $last = $wpdb->get_row("SHOW TABLE STATUS LIKE 'kbnQotes'");
        $lastid = $last->Auto_increment -1;

        // adding the entry to the log
        $title = date('Y-m-d G:i:s') . '<br /><strong> ' . $_POST['Title'] . '</strong><br />' .  $_POST['What'];

                // indsaetter ingen vaerdi i Id ... hvordan opdateres den?
                                'Id' => NULL,
                                'What' => $_POST['What'],
                                'KbnNotesId' => $lastid,
                                'KbnStatesId' => $_POST['KbnStatesId'],
                                'KbnProjectsId' => $_POST['KbnProjectsId'],
                                'KbnNotesName' => $title,
                                'Date' => date('Y-m-d G:i:s')
                                '%d', '%s', '%d', '%d', '%d', '%s', '%s'

Published by

Per Thykjaer Jensen

I am a Senior Lecturer in front- and backend web programming at the Multimedia Design and Communication Programme at Business Academy Aaarhus.

I speak several languages: PHP, Python, MySQL, JavaScript, Nodejs, HTML, CSS, and … Danish.

Background: MA it, interaction and multimedia – MA Literature history – BA Art History.

Leave a Reply