Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-10512

Create a wrapper function for ezdb to encapsulate the IN-creation

    XMLWordPrintable

    Details

      Description

      This will allow the creation of IN-parts in SQL statements that are compatible to oracle (limitation for elements used by IN is 1000).
      The function definition could look like this:

      function createIn( $column, $elements ) {}

      The mysql version is very simple and just creates an IN part as is. The oracle version could look like this:

      function createIn( $column, $elements = array() )
      {
      $amountElements = count( $elements );
      if ( $amountElements > 1000 )
      {
      $parts = array();
      $offset = 0;
      while ( $offset < $amountElements )
      {
      $length = 1000;
      if ( $offset + 1000 > $amountElements )

      { $length = $amountElements - $offset; }

      $parts[] = $column . ' IN (' . implode( ', ', array_slice( $elements, $offset, $length ) ) . ')';
      $offset += $length;
      }
      return '( ' . implode( ' OR ', $nodeParts ) . ' )';
      }
      else

      { return $column . ' IN (' . implode( ', ', $elements ) . ')'; }

      }

      This allows us to reduce redundancies, because at the moment this piece of code is inserted as needed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sp Sergiy Pushchin
              Reporter:
              ab@ez.no Alexander Block
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: