public static function parse($database, $command) { if (preg_match(self::PATTERN_INSERT_INTO, $command, $matches) > 0) { $line = $command; $table_name = $matches[1]; $columns_signature = md5($matches[2]); if (!isset(self::$columns_cache[$columns_signature])) { self::$columns_cache[$columns_signature] = $columns = self::column_split($matches[2], array('"')); } else { $columns = self::$columns_cache[$columns_signature]; } $data_row = self::column_split($matches[3], array("'")); if (count($columns) != count($data_row)) { throw new exception("column count " . count($columns) . " does not match data_row count " . count($data_row)); } // merge together as an alpha index row for ($i = 0; $i < count($columns); $i++) { $row[$columns[$i]] = $data_row[$i]; } $node_schema =& dbx::get_schema($database, sql_parser::get_schema_name($table_name, $database)); if ($node_schema == null) { throw new exception("Failed to find schema for data append: " . sql_parser::get_schema_name($table_name, $database)); } $node_table =& dbx::get_table($node_schema, sql_parser::get_object_name($table_name)); if ($node_table == null) { throw new exception("Failed to find table for data append: " . $table_name); } try { pgsql8_table::add_data_row($node_table, $row); } catch (Exception $e) { var_dump($command); throw $e; } } else { throw new exception("Cannot parse command: " . $command); } }