File: examples/activerecord/example.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil  >  PHP Skeleton Framework  >  examples/activerecord/example.php  >  Download  
File: examples/activerecord/example.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: 5 years ago
Size: 1,853 bytes


Class file image Download
include '../config.php';
#include 'A/Db/MySQL.php';
#include 'A/Db/Activerecord.php';

class projects extends A_Db_ActiveRecord
    public function
$this->setColumns(array (
$this->table('projects'); // optional in this case because base AR class will use class name as table name
$this->key('id'); // optional in this case because 'id' is the default key name

    public function
$this->data['title'].', '.$this->data['name'].' '.$this->data['surname'];

$db = new A_Db_MySQL($config['db']);
if (
$db->isError()) die('ERROR: ' . $db->getMessage());

$project = new Projects();


#$project->set('title', 'Mr');
#$project->set('name', 'Frodo');
#$project->set('surname', 'Baggins');
#$project->set('email', '');
echo 'table=' . $project->getTable() . '<br/>';




$rs = $project->getAll();
foreach ( $rs as $result ) {
    echo $result->get('fullname') ."\n";
    // OR
    echo $result->fullname ."\n";


$project->set('name', 'Frodo');


$project->set('projectID', 1);
$project->set('title', 'title');
$project->set('name', 'name');
$project->set('surname', 'surname');
$project->set('email', 'email');

$newUser = new User(1);
echo $newUser->fullname ."\n";


For more information send a message to info at phpclasses dot org.