src/DB/SQLAssembler/SQLAssembler.php
private function parseData($data, array &$params, $format = 'normal')
    {
        if (!empty($data)) {
            if (is_array($data)) {
                if (isset($data[1])) {
                    $sql_segment = $data[0];
                    if (!is_array($data[1])) {
                        $params[] = $data[1];
                    } else {
                        foreach ($data[1] as $d) {
                            $params[] = $d;
                        }
                    }
                } else {
                    if ('insert' === $format) {
                        $data_keys = $data_values = array();
                        foreach ($data as $key => $value) {
                            $data_keys[] = $key;
                            $data_values[] = '?';
                            $params[] = $value;
                        }

                        $fields = implode(',', $data_keys);
                        $values = implode(',', $data_values);
                        $sql_segment = "({$fields}) VALUES ({$values})";
                    } else {
                        $segment = '';
                        foreach ($data as $key => $value) {
                            if (is_array($value)) {
                                if (isset($value[1])) {
                                    $segment .= ", {$key} = {$value[0]}";
                                    $params[] = $value[1];
                                } else {
                                    $segment .= ", {$key} = {$value[0]}";
                                }
                            } else {
                                $segment .= ", {$key} = ?";
                                $params[] = $value;
                            }
                        }

                        $sql_segment = trim($segment, ',');
                    }
                }
            } else {
                $sql_segment = $data;
            }
        } else {
            $sql_segment = '';
        }
        return $sql_segment;
    }
private function parseData($data, array &$params, $format = 'normal')
    {
        if (!empty($data)) {
            if (is_array($data)) {
                if (isset($data[1])) {
                    $sql_segment = $data[0];
                    if (!is_array($data[1])) {
                        $params[] = $data[1];
                    } else {
                        foreach ($data[1] as $d) {
                            $params[] = $d;
                        }
                    }
                } else {
                    if ('insert' === $format) {
                        $data_keys = $data_values = array();
                        foreach ($data as $key => $value) {
                            $data_keys[] = $key;
                            $data_values[] = '?';
                            $params[] = $value;
                        }

                        $fields = implode(',', $data_keys);
                        $values = implode(',', $data_values);
                        $sql_segment = "({$fields}) VALUES ({$values})";
                    } else {
                        $segment = '';
                        foreach ($data as $key => $value) {
                            if (is_array($value)) {
                                if (isset($value[1])) {
                                    $segment .= ", {$key} = {$value[0]}";
                                    $params[] = $value[1];
                                } else {
                                    $segment .= ", {$key} = {$value[0]}";
                                }
                            } else {
                                $segment .= ", {$key} = ?";
                                $params[] = $value;
                            }
                        }

                        $sql_segment = trim($segment, ',');
                    }
                }
            } else {
                $sql_segment = $data;
            }
        } else {
            $sql_segment = '';
        }
        return $sql_segment;
    }
解析数据

@param $data
@param array $params
@param string $format
@return string