Skip to content

Commit

Permalink
Basic I/O example
Browse files Browse the repository at this point in the history
  • Loading branch information
irvingleonard committed Jun 4, 2014
0 parents commit 645fb31
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/basic.in.out/database-mysql_v5.x.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE student (
id_student INT(11) KEY AUTO_INCREMENT,
identification_number VARCHAR(11) NOT NULL,
name varchar(50) NOT NULL,
age INT(2) NULL,
preferences TEXT
)
8 changes: 8 additions & 0 deletions examples/basic.in.out/student.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
class student extends ODBObject{
public $identification_number;
public $name;
public $age;
public $preferences;
}
?>
20 changes: 20 additions & 0 deletions examples/basic.in.out/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
require_once "../objectDB/objectDB-mysql-v3.0.php"; // this will include first
require_once "student.php";

// create and set values for a new student
$student = new student();
$student->setDataFromParamsList(3025,'Salvi Pascual',24,'color=orange,grossery=pie,serie=futurama');

// save ths new student in database
$student->save();

// load all students saved until now
$db = new objectDB();
$students_list = $db->getObjs('student');

// print students
echo '<h1>List of students in database</h1>';
for($i=0; $i<count($students_list); $i++)
echo $students_list[$i] . '<br/>';
?>

0 comments on commit 645fb31

Please sign in to comment.