Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous
<p>Please help I have done all I can do to figure this out to no avail....</p>

<p>here is the error --------
a:5:{i:0;s:100:"SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous";i:1;s:3411:"#0 /home/saes/public_html/lib/Zend/Db/Statement.php(300):</p>

<p>here is the file ---------</p>

<pre><code>abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
{

/**
 * @var resource|object The driver level statement object/resource
 */
protected $_stmt = null;

/**
 * @var Zend_Db_Adapter_Abstract
 */
protected $_adapter = null;

/**
 * The current fetch mode.
 *
 * @var integer
 */
protected $_fetchMode = Zend_Db::FETCH_ASSOC;

/**
 * Attributes.
 *
 * @var array
 */
protected $_attribute = array();

/**
 * Column result bindings.
 *
 * @var array
 */
protected $_bindColumn = array();

/**
 * Query parameter bindings; covers bindParam() and bindValue().
 *
 * @var array
 */
protected $_bindParam = array();

/**
 * SQL string split into an array at placeholders.
 *
 * @var array
 */
protected $_sqlSplit = array();

/**
 * Parameter placeholders in the SQL string by position in the split array.
 *
 * @var array
 */
protected $_sqlParam = array();

/**
 * @var Zend_Db_Profiler_Query
 */
protected $_queryId = null;

/**
 * Constructor for a statement.
 *
 * @param Zend_Db_Adapter_Abstract $adapter
 * @param mixed $sql Either a string or Zend_Db_Select.
 */
public function __construct($adapter, $sql)
{
    $this-&gt;_adapter = $adapter;
    if ($sql instanceof Zend_Db_Select) {
        $sql = $sql-&gt;assemble();
    }
    $this-&gt;_parseParameters($sql);
    $this-&gt;_prepare($sql);

    $this-&gt;_queryId = $this-&gt;_adapter-&gt;getProfiler()-&gt;queryStart($sql);
}

/**
 * Internal method called by abstract statment constructor to setup
 * the driver level statement
 *
 * @return void
 */
protected function _prepare($sql)
{
    return;
}

/**
 * @param string $sql
 * @return void
 */
protected function _parseParameters($sql)
{
    $sql = $this-&gt;_stripQuoted($sql);

    // split into text and params
    $this-&gt;_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
        $sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);

    // map params
    $this-&gt;_sqlParam = array();
    foreach ($this-&gt;_sqlSplit as $key =&gt; $val) {
        if ($val == '?') {
            if ($this-&gt;_adapter-&gt;supportsParameters('positional') === false) {
                /**
                 * @see Zend_Db_Statement_Exception
                 */
                #require_once 'Zend/Db/Statement/Exception.php';
                throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$val'");
            }
        } else if ($val[0] == ':') {
            if ($this-&gt;_adapter-&gt;supportsParameters('named') === false) {
                /**
                 * @see Zend_Db_Statement_Exception
                 */
                #require_once 'Zend/Db/Statement/Exception.php';
                throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
            }
        }
        $this-&gt;_sqlParam[] = $val;
    }

    // set up for binding
    $this-&gt;_bindParam = array();
}

/**
 * Remove parts of a SQL string that contain quoted strings
 * of values or identifiers.
 *
 * @param string $sql
 * @return string
 */
protected function _stripQuoted($sql)
{
    // get the character for delimited id quotes,
    // this is usually " but in MySQL is `
    $d = $this-&gt;_adapter-&gt;quoteIdentifier('a');
    $d = $d[0];

    // get the value used as an escaped delimited id quote,
    // e.g. \" or "" or \`
    $de = $this-&gt;_adapter-&gt;quoteIdentifier($d);
    $de = substr($de, 1, 2);
    $de = str_replace('\\', '\\\\', $de);

    // get the character for value quoting
    // this should be '
    $q = $this-&gt;_adapter-&gt;quote('a');
    $q = $q[0];

    // get the value used as an escaped quote,
    // e.g. \' or ''
    $qe = $this-&gt;_adapter-&gt;quote($q);
    $qe = substr($qe, 1, 2);
    $qe = str_replace('\\', '\\\\', $qe);

    // get a version of the SQL statement with all quoted
    // values and delimited identifiers stripped out
    // remove "foo\"bar"
    $sql = preg_replace("/$q($qe|\\\\{2}|[^$q])*$q/", '', $sql);
    // remove 'foo\'bar'
    if (!empty($q)) {
        $sql = preg_replace("/$q($qe|[^$q])*$q/", '', $sql);
    }

    return $sql;
}

/**
 * Bind a column of the statement result set to a PHP variable.
 *
 * @param string $column Name the column in the result set, either by
 *                       position or by name.
 * @param mixed  $param  Reference to the PHP variable containing the value.
 * @param mixed  $type   OPTIONAL
 * @return bool
 */
public function bindColumn($column, &amp;$param, $type = null)
{
    $this-&gt;_bindColumn[$column] =&amp; $param;
    return true;
}

/**
 * Binds a parameter to the specified variable name.
 *
 * @param mixed $parameter Name the parameter, either integer or string.
 * @param mixed $variable  Reference to PHP variable containing the value.
 * @param mixed $type      OPTIONAL Datatype of SQL parameter.
 * @param mixed $length    OPTIONAL Length of SQL parameter.
 * @param mixed $options   OPTIONAL Other options.
 * @return bool
 */
public function bindParam($parameter, &amp;$variable, $type = null, $length = null, $options = null)
{
    if (!is_int($parameter) &amp;&amp; !is_string($parameter)) {
        /**
         * @see Zend_Db_Statement_Exception
         */
        #require_once 'Zend/Db/Statement/Exception.php';
        throw new Zend_Db_Statement_Exception('Invalid bind-variable position');
    }

    $position = null;
    if (($intval = (int) $parameter) &gt; 0 &amp;&amp; $this-&gt;_adapter-&gt;supportsParameters('positional')) {
        if ($intval &gt;= 1 || $intval &lt;= count($this-&gt;_sqlParam)) {
            $position = $intval;
        }
    } else if ($this-&gt;_adapter-&gt;supportsParameters('named')) {
        if ($parameter[0] != ':') {
            $parameter = ':' . $parameter;
        }
        if (in_array($parameter, $this-&gt;_sqlParam) !== false) {
            $position = $parameter;
        }
    }

    if ($position === null) {
        /**
         * @see Zend_Db_Statement_Exception
         */
        #require_once 'Zend/Db/Statement/Exception.php';
        throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$parameter'");
    }

    // Finally we are assured that $position is valid
    $this-&gt;_bindParam[$position] =&amp; $variable;
    return $this-&gt;_bindParam($position, $variable, $type, $length, $options);
}

/**
 * Binds a value to a parameter.
 *
 * @param mixed $parameter Name the parameter, either integer or string.
 * @param mixed $value     Scalar value to bind to the parameter.
 * @param mixed $type      OPTIONAL Datatype of the parameter.
 * @return bool
 */
public function bindValue($parameter, $value, $type = null)
{
    return $this-&gt;bindParam($parameter, $value, $type);
}

/**
 * Executes a prepared statement.
 *
 * @param array $params OPTIONAL Values to bind to parameter placeholders.
 * @return bool
 */
public function execute(array $params = null)
{
    /*
     * Simple case - no query profiler to manage.
     */
    if ($this-&gt;_queryId === null) {
        return $this-&gt;_execute($params);
    }

    /*
     * Do the same thing, but with query profiler
     * management before and after the execute.
     */
    $prof = $this-&gt;_adapter-&gt;getProfiler();
    $qp = $prof-&gt;getQueryProfile($this-&gt;_queryId);
    if ($qp-&gt;hasEnded()) {
        $this-&gt;_queryId = $prof-&gt;queryClone($qp);
        $qp = $prof-&gt;getQueryProfile($this-&gt;_queryId);
    }
    if ($params !== null) {
        $qp-&gt;bindParams($params);
    } else {
        $qp-&gt;bindParams($this-&gt;_bindParam);
    }
    $qp-&gt;start($this-&gt;_queryId);

    $retval = $this-&gt;_execute($params);

    $prof-&gt;queryEnd($this-&gt;_queryId);

    return $retval;
}

/**
 * Returns an array containing all of the result set rows.
 *
 * @param int $style OPTIONAL Fetch mode.
 * @param int $col   OPTIONAL Column number, if fetch mode is by column.
 * @return array Collection of rows, each in a format by the fetch mode.
 */
public function fetchAll($style = null, $col = null)
{
    $data = array();
    if ($style === Zend_Db::FETCH_COLUMN &amp;&amp; $col === null) {
        $col = 0;
    }
    if ($col === null) {
        while ($row = $this-&gt;fetch($style)) {
            $data[] = $row;
        }
    } else {
        while (false !== ($val = $this-&gt;fetchColumn($col))) {
            $data[] = $val;
        }
    }
    return $data;
}

/**
 * Returns a single column from the next row of a result set.
 *
 * @param int $col OPTIONAL Position of the column to fetch.
 * @return string One value from the next row of result set, or false.
 */
public function fetchColumn($col = 0)
{
    $data = array();
    $col = (int) $col;
    $row = $this-&gt;fetch(Zend_Db::FETCH_NUM);
    if (!is_array($row)) {
        return false;
    }
    return $row[$col];
}

/**
 * Fetches the next row and returns it as an object.
 *
 * @param string $class  OPTIONAL Name of the class to create.
 * @param array  $config OPTIONAL Constructor arguments for the class.
 * @return mixed One object instance of the specified class, or false.
 */
public function fetchObject($class = 'stdClass', array $config = array())
{
    $obj = new $class($config);
    $row = $this-&gt;fetch(Zend_Db::FETCH_ASSOC);
    if (!is_array($row)) {
        return false;
    }
    foreach ($row as $key =&gt; $val) {
        $obj-&gt;$key = $val;
    }
    return $obj;
}

/**
 * Retrieve a statement attribute.
 *
 * @param string $key Attribute name.
 * @return mixed      Attribute value.
 */
public function getAttribute($key)
{
    if (array_key_exists($key, $this-&gt;_attribute)) {
        return $this-&gt;_attribute[$key];
    }
}

/**
 * Set a statement attribute.
 *
 * @param string $key Attribute name.
 * @param mixed  $val Attribute value.
 * @return bool
 */
public function setAttribute($key, $val)
{
    $this-&gt;_attribute[$key] = $val;
}

/**
 * Set the default fetch mode for this statement.
 *
 * @param int   $mode The fetch mode.
 * @return bool
 * @throws Zend_Db_Statement_Exception
 */
public function setFetchMode($mode)
{
    switch ($mode) {
        case Zend_Db::FETCH_NUM:
        case Zend_Db::FETCH_ASSOC:
        case Zend_Db::FETCH_BOTH:
        case Zend_Db::FETCH_OBJ:
            $this-&gt;_fetchMode = $mode;
            break;
        case Zend_Db::FETCH_BOUND:
        default:
            $this-&gt;closeCursor();
            /**
             * @see Zend_Db_Statement_Exception
             */
            #require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception('invalid fetch mode');
            break;
    }
}

/**
 * Helper function to map retrieved row
 * to bound column variables
 *
 * @param array $row
 * @return bool True
 */
public function _fetchBound($row)
{
    foreach ($row as $key =&gt; $value) {
        // bindColumn() takes 1-based integer positions
        // but fetch() returns 0-based integer indexes
        if (is_int($key)) {
            $key++;
        }
        // set results only to variables that were bound previously
        if (isset($this-&gt;_bindColumn[$key])) {
            $this-&gt;_bindColumn[$key] = $value;
        }
    }
    return true;
}

/**
 * Gets the Zend_Db_Adapter_Abstract for this
 * particular Zend_Db_Statement object.
 *
 * @return Zend_Db_Adapter_Abstract
 */
public function getAdapter()
{
    return $this-&gt;_adapter;
}

/**
 * Gets the resource or object setup by the
 * _parse
 * @return unknown_type
 */
public function getDriverStatement()
{
    return $this-&gt;_stmt;
}
</code></pre>

<p>}</p>
