score:0
first, you have to create a connection string from the heroku database_url
environment variable.
function pg_connection_string_from_database_url() {
extract(parse_url($_env["database_url"]));
return "user=$user password=$pass host=$host dbname=" . substr($path, 1); # <- you may want to add sslmode=require there too
}
in order to establish a connection with the db, you can use pg_connect()
which is a built-in function in php.
$conn_str = pg_connection_string_from_database_url();
$pg_conn = pg_connect($conn_str);
after successfully connecting to the db, you can run the queries as you need.
$result = pg_query($pg_conn, "select relname from pg_stat_user_tables where schemaname='public'");
few examples on how to use postgresql can be found here in official docs
full code i used for this answer can be found here
Source: stackoverflow.com
Related Query
- How do I connect to a PostgreSQL database on Heroku server and use Chart.js?
- How to use PrimeNg Chart of Width and Height?
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- how to reduce list chart to one and use select dropdown to show selection without refresh page?
- How to use forEach loop on my array to plot x and y variables on my chart (Chart.js)
- How to use plugins in chartjs and laravel chart consoletvs/chartsjs
- How to save Chart JS charts as image without black background using blobs and filesaver?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- Chart js: how can I align the legend and the title
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- How to get the actual chart width and height in chart.js
- How to show data values in top of bar chart and line chart in chart.js 3
- How to draw a needle on a custom donut chart and add datapoints to the needle?
- How to import and use a custom Chart.js plugin in Nuxt? (Chartjs-vuejs v2.9.4)
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- How to create a gantt chart using Chart.js and populate dates?
- How to create chartjs chart with data from database C#
- How to create a chart that uses strings for both the X and Y axes?
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- How do I use my chart.js line chart with handlebars?
- Grouped Bar Chart from mySQL database using ChartJS and PHP
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- How to use segment property to color line / border color based on value in chart js?
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- Is it possible to use mouseenter and mouseleave event in chart js?
- How to use JSON data in creating a chart with chartjs?
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- How to use Chart.js to draw mixed Financial / Candlestick and Bar Chart?
More Query from same tag
- How to draw Horizontal line on Bar Chart Chartjs
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- How to trigger hover programmatically in chartjs
- How to display data values on bar graph (chart.js)?
- Stacked bar chart starting from 0 - ChartJS React
- VueJs and ChartJs - Chart is responsive in width, but not height?
- How to add tooltip for the inner doughnut
- How should i apply date picker in my chart
- Send data from a form to another component of the same level -angular
- Assigning data structures to chartjs properties, NOT individually
- label too long in yAxis with chartJs
- Make arbitrary line dashed
- How to remove some points in chartjs
- Chart JS - How to output JSON objects into PIE variant
- Calling external Chartjs chart from a javascript file into HTML in Flask
- One common component for Chart.js to use with different y-axis With React.js
- Unique identifier in Chartjs Bar segments?
- re-creating an animated graph in javascript with charts.js
- Stacked horizontal bar chart along total count with chart.js
- How to add margin bottom in Tittle ChartJS
- Chart.Js vers2 multiline to version 3
- Chart options not used with chart js
- How to make bars dashed in chart js?
- how to create multiple chart on one component vue
- Chartjs stacked bar separate tooltip for all stacked
- Chart.js add direction arrows to the X and Y axes
- How to register plot or label click event in chart.js
- Line chart with a lot of data: skip labels
- Chart Js + Angular
- Chart.js - Unable to refresh the page