PDO temporary persistent connection

I have a function for a forum that I’m working on. One of the things it does is return a result back to the ajax call and redirect

function inv_post_create_topic() {
        global $db;
        if($_POST['postas']=='support') {
            $author = '0';
        }
        else { $author = $_POST['poster']; }
        $query = <<<SQL
        INSERT INTO inv_forums(parent,subject,body,author,replies,views,enabled,posted,posttype)
        VALUES(:parent,:subject,:body,:author,:replies,:views,:enabled,:posted,:posttype)
SQL;
        $resource = $db->db->prepare( $query );
        $resource->execute( array (
        ':parent'   => $_POST['cat'],
        ':subject'  => $_POST['title'],
        ':body'     => $_POST['post'],
        ':author'   => $author,
        ':replies'  => '0',
        ':views'    => '0',
        ':enabled'  => '1',
        ':posted'   => date('F j, Y | h:i A'),
        ':posttype' => $_POST['flag'],
        ));
        echo "viewPage.php?id=".inv_get_post_redirect()."&forum=".$db->db->lastInsertId()."";
}

With this function it pulls the id with the view posts function and the last inserted ID (IE The forum just created) and then returns that data and redirects you to the newly created forum. What I was wondering is if it is at all possible to create a temporary persistent connection. It was working fine on my server,but always returned forum=0 on my live server.After some research it has to do with persistent connections being allowed. My webhost said that’s something I can set up within my config.php file, but they also let me know that the server only allows 24 concurrent connections, so what I’m trying to find out is if I can take that connection, make it persistent to pull the last id submitted and then close up afterwards.


Source: mysql

Leave a Reply