With total disregard for any kind of safety measures
lk******@geocities.com (lawrence) leapt forth and uttered:
I've downloaded and am now studying the Eclipse class libary. It
looks very elegant and well done. But as I am somewhat new to
OO, I'd like to see some example code. Documentation is thin,
save that generated by PHPdocs.
Can anyone show me some sample code? I'm mostly interested in
how other people set up their software - what objects call what
objects? What are other programmers doing in their web projects?
Is it common for people to mix OO and procedural code in their
web projects? Those who've gone the pure OO route, can I see the
constructor for your main object?
Are you referring to the Eclipse library by Vincent Oostindie?
Its not particularly hard to use as the Iterator and Database
classes work the same way across the board.
Heres an example using a MySQL database:
<?php
include_once('./MyDatabase.php');
include_once('./QueryIterator.php');
$db =& new MyDatabase('db_name', 'localhost');
if (!$db->connect('db_user', 'db_pass')) {
die('Database error: ' . $db->getErrorMessage());
}
$query =& $db->query('SELECT * FROM table');
if($query->isSuccess()) {
for($it =& new QueryIterator($query); $it->isValid(); $it->next()) {
$data =& $it->getCurrent();
echo $data['column_name'];
}
} else {
die('Query error: ' . $query->getErrorMessage());
}
?>
Using the array iterator is the same sort of thing:
<?php
include_once('./ArrayIterator.php');
$array = $_SERVER; // Just as an example
for($it =& new ArrayIterator($array); $it->isValid(); $it->next()) {
$data =& $it->getCurrent();
echo $data['key'];
}
?>
--
There is no signature.....