PHP Classes

File: examples/orm/example1.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/orm/example1.php   Download  
File: examples/orm/example1.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 707 bytes
 

Contents

Class file image Download
<?php

include('../config.php');
include(
'orm_config.php');
#include('PostMapper.php');
#include('UserMapper.php');
#include('DomainObjects.php');

$mapper = new PostMapper($db);
$post = new Post();
$post->title = 'New Title';
$post->content = 'New content...';
$post->author_id = 1;
//$mapper->insert($post);
$post->id = 2;
$mapper->update($post);
$post = $mapper->find(1);
$post->title = 'Updated Title';
$post->content = 'Updated content...';
$mapper->update($post);
$posts = $mapper->find();

$userMapper = new UserMapper($db);
$user = $userMapper->find(1);
p($user);

?>

<?php foreach ($posts as $post): ?>
<h1><?php echo $post->title; ?></h1>
<p><?php echo $post->content; ?></p>
<?php endforeach; ?>