本文整理汇总了PHP中DAO::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DAO::getConnection方法的具体用法?PHP DAO::getConnection怎么用?PHP DAO::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAO
的用法示例。
在下文中一共展示了DAO::getConnection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_start
* Date: 16/03/16
* Time: 11:33
*/
require_once 'Autoloader.php';
session_start();
// not logged in or id of photo not set
if (!isset($_SESSION['user_id'])) {
header('Location: index.php');
}
$user = new \models\Korisnik();
$user->load($_SESSION['user_id']);
if (!empty($_POST['submitted'])) {
if (isset($_POST['btnDelete'])) {
$user->delete();
unset($_SESSION['user_id']);
DAO::getConnection()->header('Location: registration.php');
exit;
}
$rules = array();
$rules['name'] = 'length[40]';
$rules['surname'] = 'length[40]';
$rules['email'] = 'required|email|length[50]';
$rules['password'] = 'required|length[100]';
$rules['confirm_password'] = 'required|length[100]';
$validation = new \validation_library\FormValidation();
$validation->set_rules($rules);
$allGood = $validation->validate();
if (strcmp($_POST['password'], $_POST['confirm_password']) != 0) {
$allGood = false;
}
if ($allGood) {
示例2: foreach
$body->add_child($link1);
$body->add_child(new \html_library\HTMLBrElement());
$title = new \html_library\HTMLTitleElement();
$title->add_child(new \html_library\HTMLTextNode('Your photos: '));
$body->add_child($title);
$body->add_child(new \html_library\HTMLBrElement());
$listElements = new \html_library\HTMLUlElement();
$images = DAO::getConnection()->getImagesByUser($_SESSION['user_id']);
foreach ($images as $imageId => $image) {
$listElement = new \html_library\HTMLLiElement();
$imgContent = new \html_library\HTMLImageElement();
$imgContent->add_attribute(new \html_library\HTMLAttribute('src', "picture.php?id={$imageId}&size=small"));
$imgTitle = new \html_library\HTMLTitleElement(3);
$imgTitle->add_child(new \html_library\HTMLTextNode($image->getTitle()));
$galleryTitle = new \html_library\HTMLTitleElement(5);
$galleryTitle->add_child(new \html_library\HTMLTextNode(DAO::getConnection()->getGallery($image->getGalleryId())->getTitle()));
$editLink = new \html_library\HTMLAElement();
$editLink->add_attribute(new \html_library\HTMLAttribute('href', "editphoto.php?id={$imageId}"));
$editLink->add_child(new \html_library\HTMLTextNode('Edit photo'));
$listElement->add_child($imgTitle);
$listElement->add_child(new \html_library\HTMLBrElement());
$listElement->add_child($imgContent);
$listElement->add_child(new \html_library\HTMLBrElement());
$listElement->add_child($galleryTitle);
$listElement->add_child(new \html_library\HTMLBrElement());
$listElement->add_child($editLink);
$listElement->add_child(new \html_library\HTMLBrElement());
$listElements->add_child($listElement);
}
$body->add_child($listElements);
echo $page;
示例3: session_start
* Time: 14:38
*/
require_once 'Autoloader.php';
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: index.php');
exit;
}
if (!empty($_POST['submitted'])) {
$rules = array();
$rules['name'] = 'required|length[100]';
$rules['description'] = 'length[500]';
$formValidation = new \validation_library\FormValidation();
$formValidation->set_rules($rules);
if ($formValidation->validate()) {
DAO::getConnection()->create(new \models\Galerija(htmlentities(trim($_POST['name'])), $_SESSION['user_id'], htmlentities(trim($_POST['description']))));
header('Location: upload.php');
exit;
} else {
$formValidation->display_validation_errors();
}
}
//page rendering
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);
$form = new \html_library\HTMLFormElement();
$body->add_child($form);
$form->add_attribute(new \html_library\HTMLAttribute('id', 'new_gallery'));
$form->add_attribute(new \html_library\HTMLAttribute('action', ''));
示例4:
$fieldset->add_child($labelDescription);
$textArea = new \html_library\HTMLTextAreaElement();
$textArea->add_attribute(new \html_library\HTMLAttribute('name', 'description'));
$textArea->add_attribute(new \html_library\HTMLAttribute('form', 'pic_upload'));
$textArea->add_attribute(new \html_library\HTMLAttribute('maxlength', 500));
$fieldset->add_child($textArea);
$textArea->add_child(new \html_library\HTMLTextNode($pictureDescription));
$fieldset->add_child(new \html_library\HTMLBrElement());
//gallery
$labelGallery = new \html_library\HTMLLabelElement();
$labelGallery->add_attribute(new \html_library\HTMLAttribute('for', 'gallery'));
$labelGallery->add_child(new \html_library\HTMLTextNode('Gallery: '));
$fieldset->add_child($labelGallery);
$selectGallery = new \html_library\HTMLSelectElement();
$selectGallery->add_attribute(new \html_library\HTMLAttribute('name', 'galleryOption'));
$galleries = DAO::getConnection()->getGalleriesByUserId($_SESSION['user_id']);
//napravi izbor korisnikovih galerija
foreach ($galleries as $galleryId => $gallery) {
$option = new \html_library\HTMLOptionElement();
$option->add_attribute(new \html_library\HTMLAttribute('value', $galleryId));
$option->add_child(new \html_library\HTMLTextNode($gallery->getTitle()));
if ($galleryId === $picture->getGalleryId()) {
$option->add_attribute(new \html_library\HTMLAttribute('selected', 'selected'));
}
$selectGallery->add_child($option);
}
$fieldset->add_child($selectGallery);
$submitInput = new \html_library\HTMLInputElement();
$submitInput->add_attribute(new \html_library\HTMLAttribute('type', 'submit'));
$submitInput->add_attribute(new \html_library\HTMLAttribute('name', 'btnSubmit'));
$submitInput->add_attribute(new \html_library\HTMLAttribute('value', 'Save changes'));
示例5: session_start
* Date: 10/03/16
* Time: 10:26
*/
require_once 'Autoloader.php';
session_start();
if (isset($_SESSION['user_id'])) {
header('Location: index.php');
}
if (!empty($_POST['submitted'])) {
$formValidation = new \validation_library\FormValidation();
$rules = array();
$rules['usermail'] = 'required|email|length[100]';
$rules['password'] = 'required|length[50]';
$formValidation->set_rules($rules);
if ($formValidation->validate()) {
$user = DAO::getConnection()->getUser($_POST['usermail'], sha1($_POST['password']));
if ($user != false) {
$_SESSION['user_id'] = $user;
header('Location: index.php');
exit;
} else {
echo "Invalid usermail or password";
}
} else {
$formValidation->display_validation_errors();
}
}
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);
示例6: array
if (!empty($_POST['submitted'])) {
$rules = array();
$rules['name'] = 'required|length[50]';
$rules['surname'] = 'required|length[50]';
$rules['email'] = 'required|email|length[100]';
$rules['password'] = 'required|length[100]';
$rules['confirm_password'] = 'required|length[100]';
$validation = new \validation_library\FormValidation();
$validation->set_rules($rules);
$allGood = $validation->validate();
if (strcmp($_POST['password'], $_POST['confirm_password']) != 0) {
$allGood = false;
}
if ($allGood) {
$user = new \models\Korisnik(htmlentities($_POST['name']), htmlentities($_POST['surname']), htmlentities($_POST['email']), sha1($_POST['password']));
DAO::getConnection()->create($user);
header('Location: login.php');
echo "Sve ok";
// exit;
} else {
if (empty($validation->validation_errors())) {
echo "Password doesn't match";
} else {
$validation->display_validation_errors();
}
}
}
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);