Fetch all news and all comments

前端 未结 3 1970
温柔的废话
温柔的废话 2021-01-17 03:33

I\'m trying to code a query that gets all the news and all the comments for each news. My current query is :

SELECT n         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-17 04:10

    I'm assuming it's returning individual records and not data structures. You're going to need to group those records yourself into the datastructure. I would hold out for some example code if possible but this can't be done directly done through SQL. (as you didn't get back PHP directly from the DB either)

    Are you using any sort of ORM? You may wish to consider looking at:

    • Rocks, Open Source ORM for PHP 5.1 plus, free software (GNU LGPL)
    • Doctrine, Open Source ORM for PHP 5.2.3, free software (GNU LGPL)
    • Propel, ORM and Query-Toolkit for PHP 5, inspired by Apache Torque, free software (GNU LGPL)
    • EZPDO, Open Source ORM for PHP 5.0.4 or newer, free software (BSD)
    • DABL, Database class creator and Query builder, inspired by Propel but easier to install, free software
    • Data Shuffler Data mapper implementation (New BSD)
    • Outlet Open source ORM (beta) for PHP 5.1.6 or newer, uses an approach similar to Hibernate (New BSD)
    • Coughphp Open source ORM for PHP5, uses code generation (It should be possible to hook up other database drivers, but out of the box only MySQL support is included.1) (FreeBSD)

    http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#PHP

提交回复
热议问题