Custom SQL Statements in Custom File Content

Tips submitted by PHPMaker users
Post Reply
Posts: 3

Custom SQL Statements in Custom File Content

Post by webguru »

  • It is recommended that you use an include in Custom Templates ... Table-Specific ... Custom File ... Content (this keeps the project file from getting bloated with your excess code). An example include would be:

  • You must add a namespace declaration in the include file with your PHPMaker version and project name to make globals and functions etc. available in the include file (in my case the project name is the name of the project file without the extension). For example:

    namespace PHPMaker2022\yourprojectname;
  • Now you can run an sql statement:

    $conn = $GLOBALS["Conn"];
    $sql = 'SELECT * FROM page';
    $rows = $conn->executeQuery($sql)->fetchAll();
    foreach ($rows as $row) {

Post Reply