public function import($src) {
		if(!file_exists(realpath($src)))
			throw new \Exception('File '.$src.' does not exist.');
		$host = $this->config['host'];
		$user = $this->config['user'];
		$pwd = $this->config['password'];
		$db = $this->config['database'];
		$cmd = 'mysql -h '.$host.' -u '.$user.($pwd ? ' -p'.$pwd:'').' '.$db.' < "'.realpath($src).'"';
		$process = proc_open($cmd,
			[
				0 => ["pipe", "r"],
				1 => ["pipe", "w"],
				2 => ["pipe", "w"],
			],
			$pipes
		);
		return proc_close($process) === 0;
	}
public function import($src) {
		if(!file_exists(realpath($src)))
			throw new \Exception('File '.$src.' does not exist.');
		$host = $this->config['host'];
		$user = $this->config['user'];
		$pwd = $this->config['password'];
		$db = $this->config['database'];
		$cmd = 'mysql -h '.$host.' -u '.$user.($pwd ? ' -p'.$pwd:'').' '.$db.' < "'.realpath($src).'"';
		$process = proc_open($cmd,
			[
				0 => ["pipe", "r"],
				1 => ["pipe", "w"],
				2 => ["pipe", "w"],
			],
			$pipes
		);
		return proc_close($process) === 0;
	}
public function import ( $ src ) { if ( ! file_exists ( realpath ( $ src ) ) ) throw new \ Exception ( 'File ' . $ src . ' does not exist.' ) ; $ host = $ this -> config [ 'host' ] ; $ user = $ this -> config [ 'user' ] ; $ pwd = $ this -> config [ 'password' ] ; $ db = $ this -> config [ 'database' ] ; $ cmd = 'mysql -h ' . $ host . ' -u ' . $ user . ( $ pwd ? ' -p' . $ pwd : '' ) . ' ' . $ db . ' < "' . realpath ( $ src ) . '"' ; $ process = proc_open ( $ cmd , [ 0 => [ "pipe" , "r" ] , 1 => [ "pipe" , "w" ] , 2 => [ "pipe" , "w" ] , ] , $ pipes ) ; return proc_close ( $ process ) === 0 ; }
Import an SQL file.
@param string $src SQL file path.
@throws \Exception When file is not accessible.
@return integer 1 for success, 0 for failure.
@api
Import an SQL file .