I’m about to launch my new upgraded phpmaker 2024 project (coming over from 2018) but I’m confused - when is it appropriate to use executescalar vs. executestatment? What’s the difference between the two? Thanks!
The ExecuteStatement is used to execute the INSERT, UPDATE, or DELETE SQLstatement, for example:
$result = ExecuteStatement("INSERT INTO ..."); // adjust the SQL to yours
if (!$result) { // Failure
$this->setFailureMessage("Inserting is failed, please try again.");
} else {
$this->setSuccessMessage("Inserting is successfully done.");
}
The ExecuteScalar is used to execute the SELECT SQL that will return a single value.
$val = ExecuteScalar("SELECT FirstName FROM employees WHERE EmployeeID = 1");
if (!empty($val)) {
$this->setSuccessMessage("Succeed, the value is " . $val);
} else {
$this->setFailureMessage("No value returned");
}