Пример #1
0
function fmExecuteSQL($connection, $query, $delimiter = '[[[COL]]]')
{
    // If the specified database connection isn't valid...
    if (!isset($connection)) {
        $error_message = 'fmExecuteSQL failed. The specified database connection is invalid.';
        die($error_message);
    }
    // Execute the query using an ExecuteSQL via fmEvaluate.
    $fm_result = fmEvaluate($connection, "ExecuteSQL ( \"" . $query . "\"; \"[[[COL]]]\", \"[[[ROW]]]\" )");
    // If rows were returned...
    if ($fm_result['Result'] != '?' and $fm_result['Result'] != '') {
        // Return the rows as an array.
        return explode('[[[ROW]]]', $fm_result['Result']);
    }
    // Return the unexpected result.
    // It will likely be an empty string (indicating that the SELECT statement returned no rows)
    // or a "?" (which indicates that the SELECT statement was invalid).
    return $fm_result['Result'];
}
Пример #2
0
}
// Strip slashes from the expression.
$_POST['q'] = stripslashes($_POST['q']);
// Set page title.
$ui_title = "FMWebFrame Demo | Evaluate";
// Start output buffering.
ob_start();
// Page header.
echo '<h1>Evaluate</h1>';
// If the form has not already been submitted...
if ($_POST['q'] == '') {
    echo '<p>With FMWebFrame\'s "fmEvaluate" function, you can tap into the power of FileMaker\'s calculation engine from within your Web applications.</p>';
    echo '<p>You can use any valid expression, including those that reference custom functions or plugins that have been installed on the server.</p>';
    echo '<p>To give fmEvaluate a try, enter an expression below.</p>';
} else {
    $result_array = fmEvaluate($fmDemo, $_POST['q']);
    if ($result_array["Result"] == '?') {
        echo '<p style="color: red;">Oops, the expression "' . $result_array["Expression"] . '" is invalid.</p>';
    } else {
        echo '<p>The expression:</p>';
        echo '<pre>' . $result_array["Expression"] . '</pre>';
        echo '<p>Evaluates to:</p>';
        echo '<pre>' . $result_array["Result"] . '</pre>';
    }
    echo '<p style="margin-top: 18px;">Try another expression.</p>';
}
echo '<form method="post" action="' . HTTP_ROOT_URL . '/application/evaluate.php">';
echo '<textarea name="q" id ="q" cols="60" rows="5">' . $_POST['q'] . '</textarea><br />';
echo 'Example: ValueListItems ( Get ( FileName ); "States" )<br />';
echo '<input type="submit" name="evaluate_form_submit" value="Evaluate" />';
echo '</form>';