fix: suppressWhitespace, убрать getDS
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
<cfsetting showdebugoutput="no" enablecfoutputonly="yes">
|
<cfprocessingdirective suppressWhitespace="true">
|
||||||
<cfheader name="Content-Type" value="application/json; charset=utf-8">
|
<cfheader name="Content-Type" value="application/json; charset=utf-8">
|
||||||
|
|
||||||
<cfset result = {ok: false, error: "unknown action"}>
|
<cfset result = {ok: false, error: "unknown action"}>
|
||||||
<cfset action = url.keyExists("action") ? url.action : "">
|
<cfset action = url.keyExists("action") ? url.action : "">
|
||||||
|
|
||||||
<cftry>
|
<cftry>
|
||||||
<cfif action EQ "test">
|
<cfif action EQ "test">
|
||||||
<cfquery name="q" datasource="baza">SELECT 1 as ok</cfquery>
|
<cfquery name="q" datasource="baza">SELECT 1 as ok</cfquery>
|
||||||
<cfset result = {ok: true, message: "PostgreSQL connected"}>
|
<cfset result = {ok: true, message: "PostgreSQL connected", db: "baza"}>
|
||||||
|
|
||||||
<cfelseif action EQ "tables">
|
<cfelseif action EQ "tables">
|
||||||
<cfquery name="q" datasource="baza">
|
<cfquery name="q" datasource="baza">
|
||||||
@@ -14,9 +15,7 @@
|
|||||||
WHERE table_schema = 'public' ORDER BY table_name
|
WHERE table_schema = 'public' ORDER BY table_name
|
||||||
</cfquery>
|
</cfquery>
|
||||||
<cfset var tables = []>
|
<cfset var tables = []>
|
||||||
<cfloop query="q">
|
<cfloop query="q"><cfset arrayAppend(tables, q.table_name)></cfloop>
|
||||||
<cfset arrayAppend(tables, q.table_name)>
|
|
||||||
</cfloop>
|
|
||||||
<cfset result = {ok: true, tables: tables}>
|
<cfset result = {ok: true, tables: tables}>
|
||||||
|
|
||||||
<cfelseif action EQ "schema">
|
<cfelseif action EQ "schema">
|
||||||
@@ -46,9 +45,7 @@
|
|||||||
<cfset var rows = []>
|
<cfset var rows = []>
|
||||||
<cfloop query="q">
|
<cfloop query="q">
|
||||||
<cfset var row = {}>
|
<cfset var row = {}>
|
||||||
<cfloop array="#cols#" index="c">
|
<cfloop array="#cols#" index="c"><cfset row[c] = q[c][q.currentRow]></cfloop>
|
||||||
<cfset row[c] = q[c][q.currentRow]>
|
|
||||||
</cfloop>
|
|
||||||
<cfset arrayAppend(rows, row)>
|
<cfset arrayAppend(rows, row)>
|
||||||
</cfloop>
|
</cfloop>
|
||||||
<cfset result = {ok: true, columns: cols, rows: rows, count: q.recordCount}>
|
<cfset result = {ok: true, columns: cols, rows: rows, count: q.recordCount}>
|
||||||
@@ -64,7 +61,8 @@
|
|||||||
</cfif>
|
</cfif>
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
||||||
<cfcatch><cfset result = {ok: false, error: cfcatch.message}></cfcatch>
|
<cfcatch><cfset result = {ok: false, error: cfcatch.message, detail: cfcatch.detail}></cfcatch>
|
||||||
</cftry>
|
</cftry>
|
||||||
|
|
||||||
<cfoutput>#serializeJSON(result)#</cfoutput>
|
<cfoutput>#serializeJSON(result)#</cfoutput>
|
||||||
|
</cfprocessingdirective>
|
||||||
|
|||||||
Reference in New Issue
Block a user