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

  • SEARCH
  • Home
  • 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 7912213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:32:33+00:00 2026-06-03T13:32:33+00:00

Using MySQL query browser, I manually made a table called users and input some

  • 0

Using MySQL query browser, I manually made a table called users and input some date in the fields. I set the primary key to id and set it to auto increment. There are 3 rows, the highest id is 3.

I then made the following class in the method directory to call upon the data in the table etc.

class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
    {
        protected $_name = 'user';  

        public function getLatestUserId()
        {
            $id = $this->getAdapter()->lastInsertId();
            return $id;
        }   
    }

In the controller I do the following which gets the value generated by the method and lets the view access it:

   $usersDbModel = new Application_Model_DbTable_User();
    $lastUserId = $usersDbModel->getLatestUserId();     
    $this->view->lastUserId = $lastUserId; 

In the view I then echo it to display it to the user:

echo $this->lastUserId;

However, even though my last id in the users table is 3. It displays 0.

I have also tried:

 public function getLatestUserId()
    {    
        $sql = 'SELECT max(id) FROM user';  
        $query = $this->query($sql);
        $result = $query->fetchAll();
        return $result;
    }   

But this just throws out a server error.

What have I done wrong?
Am I missing something?
Is there another way of doing this?

  • 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-03T13:32:34+00:00Added an answer on June 3, 2026 at 1:32 pm

    The answer was:

    $sql = 'SELECT max(id) FROM user';  
            $query = $this->getAdapter()->query($sql);
            $result = $query->fetchAll();
            return $result[0]['max(id)']; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated a table in a database using mysql query browser. is it
how to export table records as insert in mysql using mysql query browser? is
I was just creating a new table using MySQL Query Browser, and noticed there's
So I setup a table using mysql query browser, and now i'm trying to
I'm using the MySQL Query Browser (part of the MySQL GUI Tools ) and
I have been using the MySql Query Browser and [opinion]it has to be the
i am trying to pass date to mysql query using php, but i am
So, I'm using MySQL Query Browser to connect to a remote mysql server and
Does anyone know if there's a problem with the mysql query browser using connections
Okay. I've built here a mysql query browser, like navicat. Using MySQLdb to perform

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.