Returns an array of objects representing the pages in the pages table of the database.
Example
fetchAllPages()
Further Documentation:
Here is a breakdown of how the function works:
$db = DB::getInstance(); - This line gets a reference to the database connection using the getInstance() method of the DB class. This assumes that the DB class has been defined elsewhere and provides a way to interact with the database.
$query = $db->query('SELECT id, page, title, private, re_auth, core FROM pages ORDER BY id DESC'); - This line creates a SQL query that selects all columns from the pages table and orders the results by id in descending order. The result is stored in $query.
$pages = $query->results(); - This line retrieves the results of the query as an array of objects and stores it in $pages.
if (isset($row)) { return $row; } else { return $pages; } - This block of code checks to see if $row is set and returns $row if it is. If not, it returns $pages. It's not clear from this code snippet where $row is set, so it's possible that this block of code is not even being used.
Here's an example of how you might use this function in a PHP script:
// Include the necessary files and initialize the framework
require_once 'path/to/UserSpice/init.php'; init();
// Retrieve all the pages from the database $allPages = fetchAllPages();
// Do something with the results
foreach ($allPages as $page) {
echo $page->title . ' ';
}
Assuming that the fetchAllPages() function is defined in a file that has been included in the script, this code retrieves all the pages from the database and prints out the title of each page.