Hello there,
I worked for different companies and saw different ways of programming
websites.
Now everybody is talking about OO programming. But my question is: why?
Let me give you an example one of the ways I saw it done:
a class member
Class Member {
protected $_id;
protected $_name;
portected $_street;
...
public function setId($id) {
$this->_id = $id;
}
public function getId() {
return $this->_id;
}
...
public function save() {
$member = array('name' => $this->getId(), 'street',
$this->getStreet(),
...)
$db->insert($member);
}
}
When a form is posted it did:
$member = new Member();
$member->setName($this->_getParam('member')
->setStreet($this->_getParam('street');
...
$member->save();
Also when you get data from the db it will be inserted in the object, and
get from the object when you need to show it (eg in the view).
Another way (I did it) before:
Just in the controller after eg posting a form:
$data = $this->_getAllParams();
$db->insert($data);
Like you see, my way is a lot shorter :-). But comments I get is: it's not
really OO. They are true with that comment, but why should you make all
those object, all those set en gets, ... Why isn't it better to work with
arrays?
With the Zend framework IMHO you don't need to configurate all those
objects. Ok, in some systems it's better. But let's talk about
administration application, where you only have forms to input or edit,
delete and view lots of data.
What 's your meaning, why is it better to use them? ...
-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context:
http://www.nabble.com/Object-oriented-programming-with-Zend-tp25625247p25625247.html
Sent from the Zend Framework mailing list archive at Nabble.com.