<?php require_once 'function.php'; require 'classes.php'; require 'repo.php'; $link = getDbConnect(); $title = "Справочник: Ключевые слова"; $error = false; $all_wordpairs = WordpairRepository::loadAll($link); $all_persons = PersonRepository::loadAll($link); $pair_person = ''; if (isset($_POST['submit'])) { $person_id = $_POST['persons']; if ($person_id != 0) { $person = PersonRepository::load($link, $person_id); $one_person = $person->getName(); $pair_person = WordpairRepository::loadByPerson($link, $person_id); } else { $error = true; } } include 'view/header.php'; include 'view/v_wordpairs.php'; include 'view/footer.php';
<?php require_once 'function.php'; require 'classes.php'; require 'repo.php'; $link = getDbConnect(); $id = $_GET['id']; $param = $_GET['name']; switch ($param) { case 'site': if (SiteRepository::delete($link, $id)) { header("location: sites.php"); } break; case 'keyword': if (WordpairRepository::delete($link, $id)) { header("location: wordpairs.php"); } break; case 'person': if (PersonRepository::delete($link, $id)) { header("location: persons.php"); } break; default: header("location: index.php"); }
<?php require_once 'function.php'; require 'classes.php'; require 'repo.php'; $link = getDbConnect(); $title = "Личности: Редактирование"; $person_id = $_GET['id']; $person = PersonRepository::load($link, $person_id); $person_name = $person->getName(); if (isset($_POST['submit'])) { $person_name = $_POST['name']; if (PersonRepository::edit($link, $person_id, $person_name)) { header("location: persons.php"); } } include 'view/header.php'; include 'view/v_edit_person.php'; include 'view/footer.php';
<?php require_once 'function.php'; require 'classes.php'; require 'repo.php'; $link = getDbConnect(); $title = "Общая статистика"; $pids = []; $ranks = []; $error = false; $all_sites = SiteRepository::loadAll($link); $all_persons = PersonRepository::loadAll($link); if (isset($_POST['submit'])) { $site_id = $_POST['sites']; if ($site_id != 0) { $site_page = PageRepository::selectAllBySiteID($link, $site_id); //массив объектов страниц foreach ($site_page as $ids) { $pid = $ids->getId(); $pids[] = $pid; } $site = SiteRepository::load($link, $site_id); $site_name = $site->getName(); } else { $error = true; } } include 'view/header.php'; include 'view/v_static-all.php'; include 'view/footer.php';
<?php require_once 'function.php'; require 'classes.php'; require 'repo.php'; $link = getDbConnect(); $title = "Личности: Добавить"; $error = false; if (isset($_POST['submit'])) { $name = trim($_POST['name']); if ($name != "") { if (PersonRepository::add($link, $name)) { header("location: persons.php"); } } else { $error = true; } } include 'view/header.php'; include 'view/v_new_person.php'; include 'view/footer.php';
public function test_scope_overwrite_global_scope() { $repository = new \PersonRepository(new Person()); $malePeople = $repository->scope('male')->all(); $this->assertEquals(2, $malePeople->count()); $this->assertEquals("Homer", $malePeople[0]->name); $this->assertEquals("Apu", $malePeople[1]->name); }