Jump to content

Search the Community

Showing results for tags 'psql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am using php to connect to my psql database and have some initial code to connect to a database, access a table and set a column to an array etc. I, however, have been struggling to get my data into a desired format that my code is already running on. My input is in Json hierarchical data form, as following. function getData() { return { "name": "data", "children": [ { "name": "America", "children": [ { "name": "MA", "children": [ {"name": "Westborough", "order": 30}, {"name": "Southborough", "order":20} ] }, { "name": "NH", "children": [ {"name": "Nashua", "order": 12} ] }, { "name": "CA", "children": [ {"name": "SanFransico", "order": 17} ] } ] } ] }; This is the code I currently have using php: <?php // attempt a connection $dbh = pg_connect("host=localhost dbname=sample user=postgres"); if (!$dbh) { die("Error in connection: " . pg_last_error()); } // execute query $sql = "SELECT * FROM dataset"; $result = pg_query($dbh, $sql); if (!$result) { die("Error in SQL query: " . pg_last_error()); } //Sets the column at 1 to an array $arr = pg_fetch_all_columns($result, 1); // free memory pg_free_result($result); // close connection pg_close($dbh); ?> This is the format of the database table Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.