Advertisement
metalx1000

PHP sqlite3 json results

Aug 29th, 2023 (edited)
1,947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2. // Copyright (C) 2023 Kris Occhipinti
  3. // https://filmsbykris.com
  4. //
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU Affero General Public
  7. // License as published by the Free Software Foundation;
  8. // version 3 of the License.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. // Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with this program; if not, write to the Free Software Foundation,
  17. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18. // https://www.gnu.org/licenses/agpl-3.0.txt
  19.  
  20. $table = "invoices";
  21. $db = new SQLite3('db/invoices.db');
  22. $results = $db->query("SELECT * FROM $table");
  23. $data = array();
  24. while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
  25.   array_push($data,$row);
  26. }
  27. print json_encode($data);
  28. ?>
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement