Zend_Db Update and Delete

April 22nd, 2009

This is the second in a series exploring Zend_Db_Table. We finish up the project in the last video by adding Update and Delete functionality to our UserService. Grab the source code and follow along.
 

21 Responses to “Zend_Db Update and Delete”

  1. nekufa says:

    Hola! Thanks for Zend_Db screencasts :)
    Do not stop please, create more videos!
    Thanks!

  2. Kevin says:

    Thanks for this, you mention the next video is on one-many relationships. Are you going to do another on many-many?

  3. jon says:

    Hi Kevin,

    that’s the plan!

  4. Alexander says:

    Hello Jon,

    Thanks for this very nice screencast, i really love it learned a lot of it. Also all your other screencasts are great!

    But i’m real interested in the Zend_Form_Decorator i want to use the zend form but i can’t style it my way.

    I know that i can style every element every time, but that is to much work. I know that there is a way to this ones, but i can’t figure out how. If you want, please create a screencast about this.

    Alexander

  5. Fadel says:

    Hi

    we need more MVC videos please,

    Thanks!

  6. iceangel89 says:

    ya. u have been doing a very good job. i think more tutorials will be good!

    and i seem to find that there isn’t many forums for zend framework … maybe u can start 1 here? zfforums seem to kind of inactive

  7. jon says:

    I’ve thought about setting up a forum as a way of providing more feedback in a less blog-oriented manner. I’m hoping to expand how zendcasts runs in the next couple of months. A forum is a great idea.

  8. kisin says:

    great scrrencast!
    u really helping me with zf.

    im ancoius to se more of your screencasts

    thanks!

  9. iceangel89 says:

    Please have some tuts for ZF1.8 i think Zend Application and Tool will be great!

  10. Alexander says:

    Jon
    I’ve thought about setting up a forum as a way of providing more feedback in a less blog-oriented manner. I’m hoping to expand how zendcasts runs in the next couple of months. A forum is a great idea.

    That sounds like a great idea.

  11. snapshot says:

    I’m waiting for casts about Acl and Auth.
    Good job!

  12. Julien L says:

    Hi !

    I have a question about the UserService object. It isn’t better to use UsersTable class and put inside all our request to the database ?

    Best regards,
    Julien

  13. sedat says:

    Hi Kevin.
    Please don’t stop the publish extremely and excellent videos. I’m waiting the next video about “one to many and many to many db relationships” and then “ACL and AUTH” with impatience. :)

    You are making really super duper good job kevin. I say with all my sincerity.

    many many thank you ..

    ;)

  14. jon says:

    Hi Sedat,

    my name is Jon, but thanks for the feedback!

    @julien, I’m using the UserService object as a way of separating out business-related queries from configuration. In the following video (which is currently encoding on my humble machine), you’ll see that I use the UserTables class to store reference-related code. This is a design choice I’ve made on my own projects since it enables me to create small collections of re-usable queries in mini aggregates. I’m not a huge fan of MVC, where your Controller can reach into the model and pick and choose how it works with persistence objects.

  15. Sedat says:

    Hi Jon.
    I’m so sorry to write your name is kevin. I don’t now why i’m write kevin while post comment. :) . Sorry :)

  16. Hey Jon,

    I was wondering if its best practice to use a Post to update and delete records, or would AJAX be a way of making this app more user friendly? The only problem i see is if they had JavaScript disabled the AJAX way wouldn’t work.

    I was thinking you would have the delete link call some javascript to make the row disappear when you delete it and send a AJAX request to delete the row.

  17. jon says:

    AJAX is usually more user friendly IMHO, however it requires a little more thought. If you’re going to do AJAX development, you need to decide if you want JavaScript to be a requirement for your application to run correctly. Making a site that degrades gracefully requires a lot more thought, especially if you want your entire form to work either way. I did such an implementation awhile back on my blog – http://jon.lebensold.ca/development/decoupled-validation-with-zend_form-zend_validate-and-zend-mvc .

    Hope that helps!

  18. Jaroslaw says:

    Hello,

    I have a problem probably with routing.
    I got that message:
    Message:
    Stack trace:

    #0 C:\wamp\www\zend\application\views\scripts\index\update.phtml(4): Zend_Db_Table_Row_Abstract->__get(”)
    #1 C:\wamp\www\zend\library\Zend\View.php(107): include(’C:\wamp\www\zen…’)
    #2 C:\wamp\www\zend\library\Zend\View\Abstract.php(820): Zend_View->_run(’C:\wamp\www\zen…’)
    #3 C:\wamp\www\zend\library\Zend\Controller\Action\Helper\ViewRenderer.php(902): Zend_View_Abstract->render(’index/update.ph…’)
    #4 C:\wamp\www\zend\library\Zend\Controller\Action\Helper\ViewRenderer.php(923): Zend_Controller_Action_Helper_ViewRenderer->renderScript(’index/update.ph…’, NULL)
    #5 C:\wamp\www\zend\library\Zend\Controller\Action\Helper\ViewRenderer.php(962): Zend_Controller_Action_Helper_ViewRenderer->render()
    #6 C:\wamp\www\zend\library\Zend\Controller\Action\HelperBroker.php(276): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
    #7 C:\wamp\www\zend\library\Zend\Controller\Action.php(513): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
    #8 C:\wamp\www\zend\library\Zend\Controller\Dispatcher\Standard.php(285): Zend_Controller_Action->dispatch(’updateAction’)
    #9 C:\wamp\www\zend\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #10 C:\wamp\www\zend\public\index.php(34): Zend_Controller_Front->dispatch()
    #11 {main}

    Request parameters:

    array(3) {
    ["action"]=>
    string(6) “update”
    ["id"]=>
    string(2) “27″
    ["controller"]=>
    string(5) “index”
    }

    please gives me a some direction how to solve it.

    my bootstrap file is:
    setControllerDirectory(APPLICATION_PATH . ‘/controllers’);

    $frontController->setParam(’env’, APPLICATION_ENVIRONMENT);

    Zend_Layout::startMvc(APPLICATION_PATH . ‘/layouts/scripts’);

    $view = Zend_Layout::getMvcInstance()->getView();
    $view->doctype(’XHTML1_STRICT’);

    $router = $frontController->getRouter();

    $router->addRoute(
    ‘crud’,
    new Zend_Controller_Router_Route(’/index/:action/:id’, array(’controller’ => ‘index’))
    );

    unset($frontController);

    THANKS a lot!

  19. Jaroslaw says:

    Ok, I coped with IT:)

  20. Bob Lorriman says:

    Anybody know why I would be getting the error:

    Notice: Trying to get property of non-object in . . . update.phtml on line 4

    (line 4)
    ‘email’ => $this->user->email,

  21. Bob Lorriman says:

    Scratch that . . . I figured it out.

Leave a Reply

Desktop RSS feed iPhone + iPod