src/MySQLImport.php
public function read($handle)
	{
		if (!is_resource($handle) || get_resource_type($handle) !== 'stream') {
			throw new Exception('Argument must be stream resource.');
		}

		$stat = fstat($handle);

		$sql = '';
		$delimiter = ';';
		$count = $size = 0;

		while (!feof($handle)) {
			$s = fgets($handle);
			$size += strlen($s);
			if (strtoupper(substr($s, 0, 10)) === 'DELIMITER ') {
				$delimiter = trim(substr($s, 10));

			} elseif (substr($ts = rtrim($s), -strlen($delimiter)) === $delimiter) {
				$sql .= substr($ts, 0, -strlen($delimiter));
				if (!$this->connection->query($sql)) {
					throw new Exception($this->connection->error . ': ' . $sql);
				}
				$sql = '';
				$count++;
				if ($this->onProgress) {
					call_user_func($this->onProgress, $count, isset($stat['size']) ? $size * 100 / $stat['size'] : null);
				}

			} else {
				$sql .= $s;
			}
		}

		if (rtrim($sql) !== '') {
			$count++;
			if (!$this->connection->query($sql)) {
				throw new Exception($this->connection->error . ': ' . $sql);
			}
			if ($this->onProgress) {
				call_user_func($this->onProgress, $count, isset($stat['size']) ? 100 : null);
			}
		}

		return $count;
	}
public function read($handle)
	{
		if (!is_resource($handle) || get_resource_type($handle) !== 'stream') {
			throw new Exception('Argument must be stream resource.');
		}

		$stat = fstat($handle);

		$sql = '';
		$delimiter = ';';
		$count = $size = 0;

		while (!feof($handle)) {
			$s = fgets($handle);
			$size += strlen($s);
			if (strtoupper(substr($s, 0, 10)) === 'DELIMITER ') {
				$delimiter = trim(substr($s, 10));

			} elseif (substr($ts = rtrim($s), -strlen($delimiter)) === $delimiter) {
				$sql .= substr($ts, 0, -strlen($delimiter));
				if (!$this->connection->query($sql)) {
					throw new Exception($this->connection->error . ': ' . $sql);
				}
				$sql = '';
				$count++;
				if ($this->onProgress) {
					call_user_func($this->onProgress, $count, isset($stat['size']) ? $size * 100 / $stat['size'] : null);
				}

			} else {
				$sql .= $s;
			}
		}

		if (rtrim($sql) !== '') {
			$count++;
			if (!$this->connection->query($sql)) {
				throw new Exception($this->connection->error . ': ' . $sql);
			}
			if ($this->onProgress) {
				call_user_func($this->onProgress, $count, isset($stat['size']) ? 100 : null);
			}
		}

		return $count;
	}
public function read ( $ handle ) { if ( ! is_resource ( $ handle ) || get_resource_type ( $ handle ) !== 'stream' ) { throw new Exception ( 'Argument must be stream resource.' ) ; } $ stat = fstat ( $ handle ) ; $ sql = '' ; $ delimiter = ';' ; $ count = $ size = 0 ; while ( ! feof ( $ handle ) ) { $ s = fgets ( $ handle ) ; $ size += strlen ( $ s ) ; if ( strtoupper ( substr ( $ s , 0 , 10 ) ) === 'DELIMITER ' ) { $ delimiter = trim ( substr ( $ s , 10 ) ) ; } elseif ( substr ( $ ts = rtrim ( $ s ) , - strlen ( $ delimiter ) ) === $ delimiter ) { $ sql .= substr ( $ ts , 0 , - strlen ( $ delimiter ) ) ; if ( ! $ this -> connection -> query ( $ sql ) ) { throw new Exception ( $ this -> connection -> error . ': ' . $ sql ) ; } $ sql = '' ; $ count ++ ; if ( $ this -> onProgress ) { call_user_func ( $ this -> onProgress , $ count , isset ( $ stat [ 'size' ] ) ? $ size * 100 / $ stat [ 'size' ] : null ) ; } } else { $ sql .= $ s ; } } if ( rtrim ( $ sql ) !== '' ) { $ count ++ ; if ( ! $ this -> connection -> query ( $ sql ) ) { throw new Exception ( $ this -> connection -> error . ': ' . $ sql ) ; } if ( $ this -> onProgress ) { call_user_func ( $ this -> onProgress , $ count , isset ( $ stat [ 'size' ] ) ? 100 : null ) ; } } return $ count ; }
Reads dump from logical file.
@param  resource
@return int
Reads dump from logical file .