Пример #1
0
 public static function fetchAllFromDb()
 {
     global $logger;
     Faq::$staticErrors = array();
     $faqs = array();
     $sql = "SELECT * FROM bsi_faqs ORDER BY display_order";
     $query = mysql_query($sql);
     if (!$query) {
         $logger->LogError("Error: " . mysql_errno() . ". Error message: " . mysql_error());
         $logger->LogError("SQL: {$sql}");
         die("Error: " . mysql_errno() . ". Error message: " . mysql_error());
     }
     while ($row = mysql_fetch_assoc($query)) {
         $faq = Faq::fetchFromParameters($row);
         $faqs[] = $faq;
     }
     return $faqs;
 }
Пример #2
0
<?php

// TODO: Uncomment
include "access.php";
include_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
$errors = array();
$message = "";
$faq = new Faq();
if (isset($_POST['SBMT_REG'])) {
    $logger->LogInfo("Form has been submitted.");
    $faq = Faq::fetchFromParameters($_POST);
    if (!$faq->save()) {
        $logger->LogError("Error saving faq.");
        foreach ($faq->errors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        $message = "Values were updated successfully!";
        header("Location: faqs_list.php");
    }
} else {
    if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
        $logger->LogInfo("Page was called for edit of id: " . $_REQUEST['id']);
        $id = intval($_REQUEST['id']);
        $logger->LogDebug("Numeric id is: {$id}");
        $faq = Faq::fetchFromDb($id);
        if ($faq == null) {
            $logger->LogError("Invalid request. No faq with id: {$id} exists.");