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 380339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:58:46+00:00 2026-05-12T14:58:46+00:00

I want to save an object or form to the database. Only I can’t

  • 0

I want to save an object or form to the database. Only I can’t find the easiest (or normal) way for how to do this.

I found a lot of tutorials, but none seem to be easy or current. Can someone please help me with this?

I use version 1.9.3 of the Zend Framework.

  • 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-05-12T14:58:46+00:00Added an answer on May 12, 2026 at 2:58 pm

    The easiest way (aka the way using the smallest amount of code) to insert a row into a database table using Zend_Db is:

    $data = array(
        'created_on'      => '2007-03-22',
        'bug_description' => 'Something wrong',
        'bug_status'      => 'NEW'
    );
    
    $db->insert('bugs', $data);
    

    The above code will insert a new row into the bugs table whereas $db is the Zend_Db_Adapter_Abstract-subclass you created with Zend_Db::factory(). Please see Writing Changes to the Database in the Zend Framework manual for more details and the whole spectrum of features Zend_Db provides.

    For the sake of completeness, the above code will issue a query to the database similar to:

    INSERT INTO bugs (created_on, bug_description, bug_status) 
        VALUES ('2007-03-22', 'Something wrong', 'NEW')
    

    The next step would be a more sophisticated approach using Zend_Db_Table.

    EDIT:

    Given that you have a Zend_Form ($form) with the appropriate fields created_on, bug_description and bug_status and provided that you have the right filters and validators in place, adding a new row with values given in the form is as easy as

    if ($form->isValid($_POST)) {
        $db->insert('bugs', $form->getValues());
    }
    

    Storing a custom object is also very easy:

    // $bug is your custom object representing a bug
    $db->insert('bugs', array(
        'created_on'      => $bug->getCreatedOn(),
        'bug_description' => $bug->getDescription(),
        'bug_status'      => $bug->getStatus()
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 244k
  • Answers 244k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm currently reading Beginning Java Google App Engine from Apress.… May 13, 2026 at 8:03 am
  • Editorial Team
    Editorial Team added an answer The modulo operator is great for things like this. Basically… May 13, 2026 at 8:03 am
  • Editorial Team
    Editorial Team added an answer This one has been busting my chops all day, too.… May 13, 2026 at 8:03 am

Related Questions

I want to save an object or form to the database. Only I can't
I am using virtual attributes to save tags in an Entry model from a
What is the best way of creating and populating an Object from values passed
I am using ASP.NET2.0. I have created a download form with some input fields
I'm currently creating a WinForm in VB.NET bound to an access database. Basically what

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.