For those of you who want to need to know about how to load data from Database into the Custom Files using PHPMaker v2019, then here is the simple code to do that.
Note: "Include common files" not enabled for this case.
In this following example, we are using the demo project. That's why you see the "demo2019" as a part of namespace. Of course, you need to adjust it to your own project name. You may save then this Custom File as "load-data.php" (for example).
In addition, in this example, since the data that will be loaded depends on the "ID" parameter, then you may simply call it by using: load-data.php?ID=1 if you want to try it by yourself. It uses "ExecuteScalar" global function to get the value of the first column of the first record that found. Of course you may ehanced it using another global function such as "Execute", "ExecuteRow", and so forth.
I learned and know this, after going through several experiments for my AJAX, and this "load-data.php" file is the data source that I created for my AJAX Callback. Hopefully this helps you. Happy coding, everyone!
<?php
namespace PHPMaker2019\demo2019; // Don't forget to always use namespace this since v2019; adjust it to yours!
if (session_id() == "") session_start(); // Init session data
ob_start(); // Turn on output buffering
require_once "autoload.php"; // Everything is in here, so easy, right? :-)
if (!empty(Get("ID"))) { // Check the param of ID first
echo "The values is: " . ExecuteScalar("SELECT Model
FROM models
WHERE ID
= ".$_GET['ID']); // Display it whatever the result is
} else {
echo 'Unknown ID or data not found'; // If not found or ID is not supplied
}
?>