如题,求大侠们指导: 
1、请问这句代码的作用: $rows_affected = $this->db()->insert($this->get_table($table), $data); 
2、假如插入多笔数据, lastInsertId()返回值是什么?
需求:类似图片中的一次提交保存多笔数据。
	 
 
相关程序:system/dtm_model.inc.php
/**
     * 插入数据
     *
     * 面向对象数据库操作, 表名无需加表前缀, 数据也无需使用 $this->quote 进行过滤
     *
     * @param    string
     * @param    array
     * @return    int
     */
    public function insert($table, $data)
    {  
        $this->master();
        foreach ($data AS $key => $val)
        {
            $debug_data['`' . $key . '`'] = "'" . $this->quote($val) . "'";
        }
        $sql = 'INSERT INTO `' . $this->get_table($table) . '` (' . implode(', ', array_keys($debug_data)) . ') VALUES (' . implode(', ', $debug_data) . ')';
        if (DTM_APP::config()->get('system')->debug)
        {
            $start_time = microtime(TRUE);
        }
        try {
            $rows_affected = $this->db()->insert($this->get_table($table), $data);  
        } 
        catch (Exception $e) {
            show_error("Database error\n------\n\nSQL: {$sql}\n\nError Message: " . $e->getMessage(), $e->getMessage());
        }   
        if (DTM_APP::config()->get('system')->debug)
        {
            DTM_APP::debug_log('database', (microtime(TRUE) - $start_time), $sql);
        }
        $last_insert_id = $this->db()->lastInsertId();
        return $last_insert_id;
    }
 
                                     阅读全文
                                
                                
                                     收起全文