SpiffyJr's Blogaroo

Happenings of the man known as SpiffyJr

  • Home
  • About
    • Inspiration
    • Resume
  • Projects
    • Blitzaroo
    • phpRaider
    • Zend Calendar
  • Docs
    • Blitzaroo API
    • SpiffyCalendar Docs
    • SpiffyDb Docs
  • Downloads
  • Technologies
    • Doctrine ORM
    • Dojo
    • PHP
    • Zend Framework
  • Other
    • License
Twitter RSS
Category Archives: Technologies

Blogs on the technologies I use everyday.

Using column names in Zend_Db_Adapter update()

Posted on September 11, 2009 by SpiffyJr
2 comments

I’m doing an adjacency list model for a hierarchical menu system and while doing the sorting of menu items I ran into an issue with Zend_Db_Adapter::update().

public function up($cls)
{
	$table = $this->getDbTable();
	$adapter = $table->getAdapter();

	$data = array('priority' => 'priority - 1');

	$where = array($adapter->quoteInto('id = ?', $cls->getId()));
	$table->update($data, $where);
}

When the up() method is ran it sets the priority field to 0 which is incorrect. The code below which was written manually works as expected.

public function up($cls)
{
	$table = $this->getDbTable();
	$adapter = $table->getAdapter();

	// Works fine
	$sql = "UPDATE `menu` SET priority = (priority-1) WHERE id = " . $cls->getId();
	$adapter->query($sql);
}

Perhaps I’m not using the function properly but this is an oddity that should be addressed.

GD Star Rating
loading...
Categories: Zend Framework
Page 6 of 6« First«...23456
  • Recent Posts

    • Keep your Git fork clean
    • Get started with Zend Framework 2 modules!
    • More Doctrine 2 and Zend Framework integration goodies!
    • Super sexy URLs with ZF and the joy of controller plugins!
    • Formatting your API to work with dojox.data.JsonRestStore (#dojo)
  • Categories

    • Other
      • Random
    • Projects
      • Blitzaroo
      • phpRaider
      • SpiffyDb
      • View Helpers
      • Zend Calendar
    • SpiffyJr
    • Technologies
      • Dojo
      • PHP
      • Zend Framework
  • Tag Cloud

      Ajax Algorithm api Blitzaroo Blog BSD licenses calendar Cascading Style Sheets CSS database Data Formats Dojo Dojo Toolkit event Framework game Google HTML HTML element JavaScript JQuery json Languages mapper Marketing mmorpg model php Programming Projects Scripts Source code Style sheet Style Sheets Twitter Website zend Zend Framework
  • Archives

    • December 2011
    • November 2011
    • July 2011
    • April 2011
    • March 2011
    • December 2010
    • November 2010
    • October 2010
    • March 2010
    • February 2010
    • November 2009
    • October 2009
    • September 2009
© SpiffyJr's Blogaroo. Proudly Powered by WordPress | Nest Theme by YChong