/**
  * Inserts a record into the database using a series of insert columns
  * and corresponding insertvalues. Returns the insert id.
  * @param string $table
  * @param array $insertcolumns
  * @param array $insertvalues
  * @return integer $insertid
  */
 public function insertRecord($table, $insertcolumns, $insertvalues)
 {
     $table = $this->check($table);
     if (count($insertvalues) > 0 && is_array($insertvalues[0]) && count($insertvalues[0]) > 0) {
         foreach ($insertcolumns as $k => $v) {
             $insertcolumns[$k] = "`" . $this->check($v) . "`";
         }
         $insertSQL = "INSERT INTO `{$table}` ( id, " . implode(",", $insertcolumns) . " ) VALUES ";
         $pat = "( NULL, " . implode(",", array_fill(0, count($insertcolumns), " ? ")) . " )";
         $insertSQL .= implode(",", array_fill(0, count($insertvalues), $pat));
         foreach ($insertvalues as $insertvalue) {
             foreach ($insertvalue as $v) {
                 $vs[] = strval($v);
             }
         }
         $this->adapter->exec($insertSQL, $vs);
         return $this->adapter->getErrorMsg() == "" ? $this->adapter->getInsertID() : 0;
     } else {
         $this->adapter->exec("INSERT INTO `{$table}` (id) VALUES(NULL) ");
         return $this->adapter->getErrorMsg() == "" ? $this->adapter->getInsertID() : 0;
     }
 }