Search Results

Search found 5 results on 1 pages for 'pirkka'.

Page 1/1 | 1 

  • PHP and writing clean code

    - by Pirkka
    Hello Im trying to find best practices to write PHP. I just wonder is this a bad habit. For example, processing variables. $var = 1 $var = doSomething($var); $var = doSomething2($var); $var = doSomething3($var); It looks a bit awful. Here is a example of a real code that I just did: $this->rSum = explode(",", $this->options["rSum"]); $this->rSum = array_combine(array_values($this->rSum), array_fill(0, count($this->rSum), 0)); If someone could pass me some good tutorials of writing cleaner code generally it would be nice! Its me again asking stupid questions. :)

    Read the article

  • PHP: MVC and Model

    - by Pirkka
    Hello I`ve been wondering this one thing about creating models. If I make for example Page model. Is it the both: It can retrieve one row from the table or all the rows. Somehow Im mixing the objects and the database. I have thought it like this: I would have to make a Page-class that would represent one row in the table. It also would have all the basic CRUD-methods. Then I would have to do a Pages-class (somekind of collection) that would retrieve rows from the table and instantiate a Page object from each row. Is this kind of weird? If someone could explain to me the idea of model throughout.. Im again confused. Maybe Im thinking the whole OOP too difficult.. And by the way this forum is great. Hopefully people will just understand my problems. Heh. I was a long time procedural style programmer and now in 3 months I have dived into OOP and MVC and PHP frameworks and I just get more excited day by day when I explore this stuff!

    Read the article

  • PHP: OOP and methods

    - by Pirkka
    Hello I`ve been wondering how to implement methods in a class. Could someone explain me what means if one does OOP in procedural style? Here is an example: class Fld extends Model { private $file; private $properties = array(); public function init($file) { $this->file = $file; $this->parseFile(); } private function parseFile() { // parses the file foreach($this->file as $line)...... .................. $this->properties = $result; } } I mean is it a good thing to have methods like these that do operations for the class properties like that. Or should I pass the class property as method parameter... I mean this would cause error if the file property wouldnt be declared.

    Read the article

  • A bit confused about OOP and PHP.

    - by Pirkka
    Hello I have programmed with procedural style a lot before and in these few months I have decided to go OOP. Im a bit confused about OOP and PHP. Lets say I have Categories table and Pages table in my database. I would like to do a page-class and a category-class. Lets say I would have a page that showed information about the category and there would be a list of pages that belong to the category. How would I implement that in OOP way? I have thought that the category class would have a property (array) that would contain all the pages that it has. Well then comes the part that I`m confused about. Should I have a method that would get all the pages with correct categoryID from the database and should I instantiate all the rows as an Page-object? Or should I have a setPages-method in the Category-class and getAllPages-method in the Pages-class and with that method I would set all the pages to the Category-class. Huh Im lost. :D

    Read the article

  • PHP: MVC and DRY

    - by Pirkka
    Hello! Question about controllers. Can controller call it`s own class methods inside an action? EDIT: Oh sorry. I meant I dont want to repeat myself. :)

    Read the article

1