Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

OO PHP Help

Name: Anonymous 2009-07-19 8:20

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.


$data['uname'] = "root";
$data['paswd'] = "";
$data['dhost'] = "localhost";
$data['dbase'] = "content";

function connect()
{
    global $data;

    $connection    = @mysql_connect(
        $data['dhost'],
        $data['uname'],
        $data['paswd']) or die("Error connectiong: " . mysql_error());

    @mysql_select_db($data['dbase'], $connection);
       
    return $connection;

}

function close($connection)
{
    mysql_close($connection);
}

function showAll()
{
    $connection = connect();
   
    $sql = "SELECT * FROM article";
    $result = mysql_query($sql);
   
    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 />';
        }
    }
   
    close($connection);
   
}

function getArticle($id)
{
    $connection = connect();
    $sql = "SELECT * FROM article WHERE id='$id'";
    $result = mysql_query($sql);
   
    if ($result)
    {
        $row = mysql_fetch_assoc($result);
        $articleinfo[] = $row;
    }
   
    return $articleinfo;
    close($connection);
   
}

Name: !3LrT5NRVks 2009-07-19 17:41

>>9
Your suggesting that Lisp is not a toy language? Oh, wow.
This conversation is over.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List