src/NotORM/Result.php
function insert_multi(array $rows, $isIgnore = false){
        if($this->notORM->freeze){
            return false;
        }
        if(!$rows){
            return 0;
        }
        $data       = reset($rows);
        $parameters = array();
        if($data instanceof NotORM_Result){
            $parameters = $data->parameters; //! other parameters
            $data       = (string) $data;
        }elseif($data instanceof Traversable){
            $data = iterator_to_array($data);
        }
        $insert = $data;
        if(is_array($data)){
            $values = array();
            foreach($rows as $value){
                if($value instanceof Traversable){
                    $value = iterator_to_array($value);
                }
                $values[] = $this->quote($value);
                foreach($value as $val){
                    if($val instanceof NotORM_Literal && $val->parameters){
                        $parameters = array_merge($parameters, $val->parameters);
                    }
                }
            }

            $quoteChar = $this->getQuoteChar();

            //! driver specific extended insert
            $insert = ($data || $this->notORM->driver == "mysql")
                ? "({$quoteChar}" . implode("{$quoteChar}, {$quoteChar}", array_keys($data)) . "{$quoteChar}) VALUES " . implode(", ", $values) 
                : "DEFAULT VALUES";
        }

        // @dogstar 20181208
        $ignoreSql = $isIgnore ? 'IGNORE' : '';

        // requires empty $this->parameters
        $return = $this->query("INSERT $ignoreSql INTO $this->table $insert", $parameters);
        if(!$return){
            return false;
        }
        $this->rows = null;
        return $return->rowCount();
    }
function insert_multi(array $rows, $isIgnore = false){
        if($this->notORM->freeze){
            return false;
        }
        if(!$rows){
            return 0;
        }
        $data       = reset($rows);
        $parameters = array();
        if($data instanceof NotORM_Result){
            $parameters = $data->parameters; //! other parameters
            $data       = (string) $data;
        }elseif($data instanceof Traversable){
            $data = iterator_to_array($data);
        }
        $insert = $data;
        if(is_array($data)){
            $values = array();
            foreach($rows as $value){
                if($value instanceof Traversable){
                    $value = iterator_to_array($value);
                }
                $values[] = $this->quote($value);
                foreach($value as $val){
                    if($val instanceof NotORM_Literal && $val->parameters){
                        $parameters = array_merge($parameters, $val->parameters);
                    }
                }
            }

            $quoteChar = $this->getQuoteChar();

            //! driver specific extended insert
            $insert = ($data || $this->notORM->driver == "mysql")
                ? "({$quoteChar}" . implode("{$quoteChar}, {$quoteChar}", array_keys($data)) . "{$quoteChar}) VALUES " . implode(", ", $values) 
                : "DEFAULT VALUES";
        }

        // @dogstar 20181208
        $ignoreSql = $isIgnore ? 'IGNORE' : '';

        // requires empty $this->parameters
        $return = $this->query("INSERT $ignoreSql INTO $this->table $insert", $parameters);
        if(!$return){
            return false;
        }
        $this->rows = null;
        return $return->rowCount();
    }
function insert_multi ( array $ rows , $ isIgnore = false ) { if ( $ this -> notORM -> freeze ) { return false ; } if ( ! $ rows ) { return 0 ; } $ data = reset ( $ rows ) ; $ parameters = array ( ) ; if ( $ data instanceof NotORM_Result ) { $ parameters = $ data -> parameters ; //! other parameters $ data = ( string ) $ data ; } elseif ( $ data instanceof Traversable ) { $ data = iterator_to_array ( $ data ) ; } $ insert = $ data ; if ( is_array ( $ data ) ) { $ values = array ( ) ; foreach ( $ rows as $ value ) { if ( $ value instanceof Traversable ) { $ value = iterator_to_array ( $ value ) ; } $ values [ ] = $ this -> quote ( $ value ) ; foreach ( $ value as $ val ) { if ( $ val instanceof NotORM_Literal && $ val -> parameters ) { $ parameters = array_merge ( $ parameters , $ val -> parameters ) ; } } } $ quoteChar = $ this -> getQuoteChar ( ) ; //! driver specific extended insert $ insert = ( $ data || $ this -> notORM -> driver == "mysql" ) ? "({$quoteChar}" . implode ( "{$quoteChar}, {$quoteChar}" , array_keys ( $ data ) ) . "{$quoteChar}) VALUES " . implode ( ", " , $ values ) : "DEFAULT VALUES" ; } // @dogstar 20181208 $ ignoreSql = $ isIgnore ? 'IGNORE' : '' ; // requires empty $this->parameters $ return = $ this -> query ( "INSERT $ignoreSql INTO $this->table $insert" , $ parameters ) ; if ( ! $ return ) { return false ; } $ this -> rows = null ; return $ return -> rowCount ( ) ; }
Shortcut for call_user_func_array(array($this, 'insert'), $rows)

@param array $rows 待批量添加的数据
@param boolean $isIgnore 是否在插入时使用IGNORE

@return int number of affected rows or false in case of an error
Shortcut for call_user_func_array ( array ( $this insert ) $rows )