I need some help learning Object Oriented PHP, and I am the type to learn from examples, so I was wondering if one of you kind gentleman could rewrite this file so that is OO.
function __destruct()
{
mysql_close($this->connection);
}
function showAll()
{
$sql = "SELECT * FROM article";
$result = mysql_query($sql,$this->connection);
if ($result)
{
while ($row = mysql_fetch_array($result))
{
echo '<a href="/admin/index.php?id='.$row['id'].'">'.$row['title'].'</a> - <a href="/admin/edit.php?id='.$row['id'].'">EDIT</a> - <a href="/admin/admin.php?a=delete&id='.$row['id'].'">DELETE</a><br />';
}
}
}
function getArticle($id)
{
$sql = "SELECT * FROM article WHERE id='$id';
$result = mysql_query($sql,$this->connection);
if ($result)
{
$row = mysql_fetch_assoc($result);
$articleinfo[] = $row;
}
return $articleinfo;
}
}
Name:
!3LrT5NRVks2009-07-19 16:57
If you want to do OOP for a web page you should stick to java. OOP in php leaves much to be desired.(and all other languages not designed from the ground to do OOP... i'm looking at you LISP)
Name:
Anonymous2009-07-19 17:01
>>8
You're saying that CLOS leaves something to be desired compared to Java? Oh, wow.
Name:
Anonymous2009-07-19 17:13
>>9
CLOS has one of the exact same critical flaws as Java: Primitives aren't objects.
Multi-dispatch is nice, though.
Name:
!3LrT5NRVks2009-07-19 17:41
>>9
Your suggesting that Lisp is not a toy language? Oh, wow.
This conversation is over.
Name:
Anonymous2009-07-19 17:56
>>10 object n. 1. any Lisp datum.
You're mixing up classes and objects. Classes are useful only when you wish to have an object that contributes to the structure and behavior of a set of objects. Being able to avoid them entirely is a feature.
>>11
Hey, you. Get away from my habit of occasionally using a trip with no name.
Name:
Anonymous2009-07-19 19:48
>>12
Haskell completely separates the concerns of defining types and assigning them to classes, so that any built-in type can always be added to a class. I'd like to see a Lisp object system based on that model.
>>14
Erm so how do you instantiate an object in Haskell if you don't know the constructors until....? Actually, come to think of it, I have no fucking clue what you're on about. I can only assume that Haskell is designed as the perfect language for insane trolls from the ground up
>>14,15
Where the fuck did this "Haskell is OOP" meme come from? Typeclasses have NOTHING TO DO with OO classes. Zero. Zilch. They're completely unrelated in every way possibly imaginable.
Name:
Anonymous2009-07-20 0:21
>>14
I don't know Haskell, but I think a type in CL is similar to a Haskell type class. Obviously neither apply to object systems.
Name:
Anonymous2009-07-20 0:25
it's not learning if someone else does it for you, fuck off