Пример #1
0
<?php

header("Content-Type: text/html; charset=utf-8");
require_once './includes/initialize.php';
function __autoload($class_name)
{
    if ($class_name != 'DbSimple_Mysqli' && $class_name != 'Smarty') {
        require_once CLASS_PATH . '/class.' . $class_name . '.php';
    }
}
$smarty->assign('lesson_number', 10);
$smarty->assign('organization_form', array('0' => 'Частное лицо', '1' => 'Организация'));
$smarty->assign('cities', City::get_column_values('name'));
$smarty->assign('labels', Category::find_all_categories());
$smarty->assign('subcategories', Category::get_array_of_subcategories());
$object_storage = Ad::find_all();
$edit_id = '';
if (request_is_post()) {
    $tmp_post = $_POST;
    //escape POST array; can be more complex
    foreach ($tmp_post as $key => $value) {
        $tmp_post[$key] = strip_tags($value);
    }
    //checking checkbox. if it's not checked then there is no value in POST array
    if (!isset($tmp_post['allow_mails'])) {
        $tmp_post['allow_mails'] = "";
    }
    $ad = Ad::build($tmp_post);
    //create new object
    $ad->save();
    //save object in database
Пример #2
0
 /**
  * Get all records of ad from database
  * 
  * @global type $database
  * @return type
  */
 public function fillStorage()
 {
     global $database;
     $this->ads = Ad::find_all();
     return self::$instance;
 }