Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:24:39+00:00 2026-06-11T19:24:39+00:00

Ok this is a 2 part question, first primary concern is the nextval() bit.

  • 0

Ok this is a 2 part question, first primary concern is the nextval() bit. I have a table where one of the columns is an auto incrementing column. Being fairly new to postgres and Zend DB I am running into trouble. Inserting a new row on to a table.

This is what i have thus far (and in the CLI this works). But not in the Zend DB stuff..

class Comments extends Zend_Db_Table_Abstract
{

    protected $_name = 'comments';

    public function setComment($comment_id = null, $id = null, $comment = null)
    {
        if(($comment_id == null)||(empty($comment_id))||(trim($comment_id) == '')){return false;}
        if(($id == null)||(empty($id))||(trim($id) == '')){return false;}
        if(($comment == null)||(empty($comment))||(trim($comment) == '')){return false;}

        echo 'check one';

        $db = Zend_Db_Table::getDefaultAdapter();
        if($comment_id == "none")
        {
            $created = time()*1000;
            $data = array(
                        "comment_id" => nextval('comments_comment_id_seq'),
                        "comment" => $comment,
                        "comment_level" => 1,
                        "is_active" => true,
                        "status" => 0,
                        "id" => $id,
                        "user_id" => $_SESSION['role']['user_id'],
                        "ts_create" => $created,
                        "ts_mod" => $created
                    );
            $table->insert($data);
            return true;
        }

    }
}

The Error I am getting is:

Fatal error: Call to undefined function nextval() in
/home/src/branches/portal/application/model/Comments.php
on line 45

So Not really sure how to adjust for that. I am more familiar with mySQL where I could just drop NULL and it would auto increment. So all in all the big problem is the nextval, does Zend DB have anything in the framework that I can fix this issue with?

Next part, since this is a two part question. By using $table->insert($data); is that going to automatically use the $_name variable? I read through the Zend doc on the subject but its confusing me a bit currently as how to define the right table in the case of an insert.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:24:40+00:00Added an answer on June 11, 2026 at 7:24 pm

    Use this:

    "comment_id" => new Zend_Db_Expr("nextval('comments_comment_id_seq')"),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is kinda....a two part question. The first one is much more important than
This is a multi-part question. I have a table similar to: CREATE TABLE sales_data
This might be a 2 part question. First one is what am I doing
This is a two-part question: First, I am interested to know what the best
This is really a three-part question, but I've answered the first question myself: I'm
This is a two part question. The first is how do you properly close
This is a two part question, but I want to make sure the first
The first part of this question is actually a request for confirmation based on
The first part of this question is now its own, here: Analyzing Text for
This is two part question: I have two stored procedures: sp1 & sp2. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.