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

Related Questions

I want to be able to save any C# object in a single column
I want to save my canvas into MySQL database (BLOB cell). I have function
I want to build a form where users can enter some data in a
i have a form for adding people object ,i want to add as many
I want to save the objects I generated in a program. After restart the
I want to create own filetype to save objects in my app. Basically, I
I want to save and store simple mail objects via serializing, but I get
I want to save my program's DataModel objects to a file, and be able
I want to save one of my entity objects into the session, but as
I want save the username and password when user login, and I added the

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.