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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:00:54+00:00 2026-05-14T04:00:54+00:00

I have defined a function in my Navigation model that executes a query, and

  • 0

I have defined a function in my Navigation model that executes a query, and I was wondering if there’s a more “Zendy” way of generating/executing the query. The query I’m using was proposed by Bill Karwin on another thread here for setting arbitrary record order. I tried using a prepared statement, but the values in the SIGN() function got quoted.

I’m using the PDO adapter for MySQL.

/**
 *
 */
public function setPosition($parentId, $oldPosition, $newPosition)
{
    $parentId = intval($parentId);
    $oldPosition = intval($oldPosition);
    $newPosition = intval($newPosition);
    $this->getAdapter()->query("
        UPDATE `navigation`
        SET `position` = CASE `position`
            WHEN $oldPosition THEN $newPosition
            ELSE `position` + SIGN($oldPosition - $newPosition)
            END
        WHERE `parent_id` = $parentId
        AND `position` BETWEEN LEAST($oldPosition, $newPosition)
            AND GREATEST($oldPosition, $newPosition)
    ");
    return $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-05-14T04:00:54+00:00Added an answer on May 14, 2026 at 4:00 am

    You could use Zend_Db_Select and/or Zend_Db_Expr, but if it works like it is, don’t change it. There is really no need to use any of the ZF components just because they exist or to make your code more Zendy. Use them to solve a specific problem.

    Keep in mind that every abstraction will make your code some degrees slower. Might not be much, but also might not be necessary. I can speak from my own experience from a project where we succumbed to use as many ZF components as possible, even though we could have done without and simpler. Didn’t pay off and we found ourselves refactoring out a lot of them later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you create a database use only lower case letters… May 16, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer Given the filename patterns in your example, this will do… May 16, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer <tr> <?php $c = 0; // Our counter $n =… May 16, 2026 at 5:30 pm

Trending Tags

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

Top Members

Related Questions

I have a user defined function in a SQL Server 2005 database which returns
In PHP, I have created a user defined function. Example: <?php function test($one, $two)
I have a problem. I would like to use the animate() function to slide
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
I have PHP file where I have defined the server access variables as well
I have been able to create php function to determine a list of zip
I have a table that contains a GEOMETRY data type. SQL Server 2008 ships
In my backend I'm using jquery 1.4.1 and the newest UI 1.8rc1. I defined
I have to manipulate some Excel documents with C#. It's a batch process with
I have a page-scoped component, which has an instance variable List with data, which

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.