PMA\libraries\plugins\import\ImportShp::readFromBuffer PHP Method

readFromBuffer() public static method

Buffer automatically fetches next chunk of data when the buffer falls short. Sets $eof when $GLOBALS['finished'] is set and the buffer falls short.
public static readFromBuffer ( integer $length ) : string
$length integer number of bytes
return string
    public static function readFromBuffer($length)
    {
        global $buffer, $eof;
        if (strlen($buffer) < $length) {
            if ($GLOBALS['finished']) {
                $eof = true;
            } else {
                $buffer .= PMA_importGetNextChunk();
            }
        }
        $result = substr($buffer, 0, $length);
        $buffer = substr($buffer, $length);
        return $result;
    }

Usage Example

示例#1
0
 /**
  * Reads given number of bytes from SHP file
  *
  * @return string|false
  */
 public function readSHP($bytes)
 {
     return ImportShp::readFromBuffer($bytes);
 }