original_string: public function isQueryAllowed( ezcDbHandler $db, $query )
      {
          if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
          {
              return false;
          }
  
          if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
          {
              $tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
  
              $result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
              if ( $result[0]['count'] == 1 )
              {
                  $sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
                  array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
                  foreach ( $sequences as $sequenceName )
                  {
                      // try to drop sequences related to dropped table.
                      if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
                      {
                          $db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
                      }
                  }
                  return true;
              }
              else
              {
                  return false;
              }
          }
  
          return true;
      }
code: public function isQueryAllowed( ezcDbHandler $db, $query )
      {
          if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
          {
              return false;
          }
  
          if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
          {
              $tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
  
              $result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
              if ( $result[0]['count'] == 1 )
              {
                  $sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
                  array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
                  foreach ( $sequences as $sequenceName )
                  {
                      // try to drop sequences related to dropped table.
                      if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
                      {
                          $db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
                      }
                  }
                  return true;
              }
              else
              {
                  return false;
              }
          }
  
          return true;
      }
code_tokens: public function isQueryAllowed ( ezcDbHandler $ db , $ query ) { if ( strstr ( $ query , 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later. { return false ; } if ( substr ( $ query , 0 , 10 ) == 'DROP TABLE' ) { $ tableName = substr ( $ query , strlen ( 'DROP TABLE "' ) , - 1 ) ; // get table name without quotes $ result = $ db -> query ( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" ) -> fetchAll ( ) ; if ( $ result [ 0 ] [ 'count' ] == 1 ) { $ sequences = $ db -> query ( "SELECT sequence_name FROM user_sequences" ) -> fetchAll ( ) ; array_walk ( $ sequences , create_function ( '&$item,$key' , '$item = $item[0];' ) ) ; foreach ( $ sequences as $ sequenceName ) { // try to drop sequences related to dropped table. if ( substr ( $ sequenceName , 0 , strlen ( $ tableName ) ) == $ tableName ) { $ db -> query ( "DROP SEQUENCE \"{$sequenceName}\"" ) ; } } return true ; } else { return false ; } } return true ; }
docstring: Checks if query allowed.
  
  Perform testing if table exist for DROP TABLE query
  to avoid stoping execution while try to drop not existent table.
  
  @param ezcDbHandler $db
  @param string       $query
  
  @return boolean false if query should not be executed.
docstring_tokens: Checks if query allowed .