public function transfer($source_db,$select_query,$dest_db,$insert_query)
    {
        $result = $this->query($select_query,$source_db);
        if (!$result) {
            return false;
        }
        if ($this->numRows($result) == 0) {
            return true;
        }

        $numFields = $this->numFields($result,$source_db);

        $prep = $insert_query . ' VALUES(';
        $arg_sets = array();
        $big_query = $insert_query . ' VALUES ';
        $big_values = '';
        $big_args = array();

        while ($row = $this->fetchArray($result,$source_db)) {
            $big_values .= '(';
            $args = array();
            for ($i=0; $i<$numFields; $i++) {
                $type = strtolower($this->fieldType($result,$i,$source_db));
                $row[$i] = $this->sanitizeValue($row[$i], $type);
                $args[] = $row[$i];
                $big_args[] = $row[$i];
                $big_values .= '?';
                  /**
                  Since we can be dealing with very large strings here, it
                  could be more memory efficient to avoid adding the last
                  comma just to remove it again with a substr() call.
                */
                if ($i < $numFields-1) {
                    $big_values .= ',';
                }
            }
            $arg_sets[] = $args;
            /**
              If the limit's exceeded and the data won't be
              sent as one giant query there's no need to continue
              building components of that query.
            */
            if (count($arg_sets) < 500) {
                $big_values .= '),';
            } else {
                $big_values = '';
                $big_args = array();
            }
        }
        $big_values = substr($big_values, 0, strlen($big_values)-1);
        $prep .= str_repeat('?,', count($arg_sets[0]));
        $prep = substr($prep, 0, strlen($prep)-1) . ')';

        /**
          Sending all records as a single query for large
          record sets may present problems depending on
          underlying DBMS and/or configuration limits.
          MySQL max_allowed_packet is probably the most
          common one.
        */
        if (count($arg_sets) < 500) {
            $this->lockTimeout(5, $dest_db);
            $big_prep = $this->prepare($big_query . $big_values, $dest_db);
            $bigR = $this->execute($big_prep, $big_args, $dest_db);
            return ($bigR) ? true : false;
        } else {
            return $this->executeAsTransaction($prep, $arg_sets, $dest_db);
        }
    }