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?
                $wpdb->insert(
                        "KbnQog",
                        array(
                                'Id' => NULL,
                                'What' => $_POST['What'],
                                'KbnNotesId' => $lastid,
                                'KbnStatesId' => $_POST['KbnStatesId'],
                                'KbnProjectsId' => $_POST['KbnProjectsId'],
                                'KbnNotesName' => $title,
                                'Date' => date('Y-m-d G:i:s')
                        ),
                        array(
                                '%d', '%s', '%d', '%d', '%d', '%s', '%s'
                        )
                );

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close