[Year 12 SofDev] Records in PHP
Laurie Savage
sav at pvgc.vic.edu.au
Thu Jul 15 07:25:07 EST 2010
I was playing with an idea along the lines of
class Student{
public $name;
public $age;
public $class;
public function writeStudent(){
$fileName = $this-> name.".csv";
$fh = fopen($fileName, a+);
$contents = "$this->name, $this->age, $this->class";
fwrite($fh, $contents);
}
}
$johnny = new Student;
$johnny->name = "Johnny";
$johnny->age = 12;
$johnny->class = "6A";
$johny->writeStudent();
$liza = new Student etc
which creates a data file for each student.
Laurie Savage
Pascoe Vale Girls College
Just recently, on Wed, Jul 14, 2010 at 07:22:21PM +1000 in fact, Kevork Krozian mentioned:
> Hi Folks,
>
> This is where it gets interesting to store a record in PHP ( in memory or in a file ).
> See http://www.designdetector.com/archives/04/10/FlatFileDatabaseDemo.php#database. Basically it is a very painful process without a database.
> An associative array can represent a record. And an array of associative arrays can represent an array of records. These are effectively multidemensional arrays.
> As for classes, I wouldn't think it necessary to represent a record as such as in the serial or a sequential file example in the Fitzpatrick book in the quote from Laurie.
> Interestingly the syntax for a class is :
>
> <?php
> class student {
> var $fname = "john";
> var $surname = "smith";
> var $age = "17";
> }
> $myStudent = new student();
> echo "Student details".$myStudent->fname." " .$myStudent-> surname." " .$myStudent->age;
> ?>
>
> It does look and feel like a record. It is the class definition and instantiation that might throw the students I am thinking.
>
> Keep well
>
> Kevork Krozian
> Digital Learning Manager
> Forest Hill College
> k.krozian at fhc.vic.edu.au
> Tel: 0419 356 034
> ________________________________________
> From: sofdev-bounces at edulists.com.au [sofdev-bounces at edulists.com.au] On Behalf Of David Dawson [David.Dawson at wesleycollege.net]
> Sent: Wednesday, 14 July 2010 11:23 AM
> To: sofdev at edulists.com.au
> Subject: Re: [Year 12 SofDev] Records in PHP
>
> I am not sure of what the text says ( I use the other book :) but records per se are not basic data types.
> In PHP you can use a CSV file to store records and then process these using a simple array where the array position is a "field" and every element is initially a string.
>
>
> David Dawson
> Head of Information Technology Learning Area
> Head of Learning Technologies
> St Kilda Rd Campus
> Wesley College
> 577 St Kilda Rd
> Melbourne 3004
> Ph 8102 6340
> Mob 0425 718147
>
>
> >>> sofdev-bounces at edulists.com.au 07/14/10 8:40 am >>>
>
>
> This is my first time teaching SD. We’re using PHP and the Fitzpatrick/Keane text. PHP doesn’t have a specific type called a “record” and a single vector array doesn’t seem to match the concept as illustrated (fig 6.5, page 162). Looking at the example in the text I’m wondering if I could describe it as an instance of a class?
>
>
>
> Laurie Savage
>
> Pascoe Vale Girls College
>
>
>
>
> ____________________________________________________________________________
>
> Sapere Aude - Dare To Be Wise
>
> Wesley College Melbourne is a world class coeducational independent school
> developing the whole person through timeless principles of learning:
> - to know
> - to do
> - to live with
> - to be
> with innovation and wisdom
>
> ABN 38 994 068 473 CRICOS 00354G
> ____________________________________________________________________________
>
> This email is intended only for the use of the individual or entity named
> above and may contain information that is confidential and privileged. If
> you are not the intended recipient, you are hereby notified that any
> dissemination, distribution or copying of this email is strictly prohibited.
> If you have received this email in error, please email a reply to Wesley
> College and destroy the original message.
>
>
> _______________________________________________
> http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
> IT Software Development Mailing List kindly supported by
> http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
> http://www.vitta.org.au/vce/studies/infotech/softwaredevel3-4.html
> http://www.vitta.org.au - VITTA Victorian Information Technology Teachers Association Inc
> _______________________________________________
> http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
> IT Software Development Mailing List kindly supported by
> http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
> http://www.vitta.org.au/vce/studies/infotech/softwaredevel3-4.html
> http://www.vitta.org.au - VITTA Victorian Information Technology Teachers Association Inc
--
Laurie Savage
====================================================================
Markbook/Moodle Coordinator::Pascoe Vale Girls College::03 9306 2544
====================================================================
You are standing on my toes.
More information about the sofdev
mailing list