Doctrine 1
  1. Doctrine 1
  2. DC-794

findBy issue with field names containing "Or"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.2.3
    • Component/s: Record
    • Labels:
      None
    • Environment:
      Tested with Windows Vista / Ubuntu 10.4, PHP 5.2.10, MySQL 5.

      Description

      The problem is in Doctrine_Table::buildFindByWhere, line 2715. I put the code here for clarity:

      public function buildFindByWhere($fieldName)
      {
      $ands = array();
      $e = explode('And', $fieldName);
      foreach ($e as $k => $v) {
      $and = '';
      $e2 = explode('Or', $v);<- LINE 2715
      $ors = array();
      foreach ($e2 as $k2 => $v2) {
      if ($v2 = $this->_resolveFindByFieldName($v2))

      { $ors[] = 'dctrn_find.' . $v2 . ' = ?'; }

      else

      { throw new Doctrine_Table_Exception('Invalid field name to find by: ' . $v2); }

      }
      $and .= implode(' OR ', $ors);
      $and = count($ors) > 1 ? '(' . $and . ')':$and;
      $ands[] = $and;
      }
      $where = implode(' AND ', $ands);
      return $where;
      }

      In my proyect I have a table called OrigenesOportunidadCliente, which id field name is idOrigenOportunidadCliente. As you have probably noticed, the name contains Or: idOrigenOportunidadCliente. And there is where it fails, it gets as if there where an OR statement, not finding a valid field name in the below foreach as the field is "OrigenOportunidad".

        Activity

        Show
        Enrico Stahn added a comment - fixed http://github.com/estahn/doctrine1/compare/master...DC-794
        Hide
        Jonathan H. Wage added a comment -
        Show
        Jonathan H. Wage added a comment - Fixed in http://trac.doctrine-project.org/changeset/7681 Thanks
        Hide
        Eduardo Gulias Davis added a comment -

        Sorry for the delay in posting this comment!!

        thank you very very much for the quick response on this issue.

        Great work!

        Show
        Eduardo Gulias Davis added a comment - Sorry for the delay in posting this comment!! thank you very very much for the quick response on this issue. Great work!

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Eduardo Gulias Davis
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: