Topic: help translate php to coldfusion code


zionist    -- 01-14-2009 @ 1:09 AM
  hi guys could someone please help me and translate this php script to coldfusion. thanks

UserInfoService.php:
<?php
class UserInfoService
{
    function getUserInfo(UserCredentials $userCredentials)
    {
        require_once("Classes/UserInfo.php");
        require_once("Classes/UserCredentials.php");
        $userInfo = new UserInfo();
        $userInfoDB = new mysqli("myserver.com", "user", "pass", "DB");
        $query = "SELECT * FROM UserInfo where username='" . $userCredentials->username . "' AND password='" . $userCredentials->password . "'";
        if($result = $userInfoDB->query($query))
        {
            if($result->num_rows == 1)
            {
                $row = $result->fetch_assoc();
                $userInfo->username = $row["username"];
                $userInfo->password = $row["password"];
                $userInfo->firstname = $row["firstname"];
                $userInfo->lastname = $row["lastname"];
                $userInfo->email = $row["email"];
            }
        }
        return $userInfo;
    }
  
    function loginUser(UserCredentials $userCredentials)
    {
        require_once("Classes/UserCredentials.php");
        $loginResult = "Failure";
        $userInfoDB = new mysqli("myserver.com", "user", "pass", "DB");
        $query = "SELECT * FROM UserInfo where username='" . $userCredentials->username . "' AND password='" . $userCredentials->password . "'";
        if($result = $userInfoDB->query($query))
        {
            if($result->num_rows == 1)
            {
                $loginResult = "Success";
            }
        }
        return $loginResult;
    }
}
?>

Classes/UserInfo.php:
<?php
class UserInfo
{
    public $username;
    public $password;
    public $firstname;
    public $lastname;
    public $email;
}
?>

Classes/UserCredentials.php:
<?php
class UserCredentials
{
    public $username;
    public $password;
}
?>



EasyCFM.COM ColdFusion Forums : http://archive.easycfm.com/forums
Topic: http://archive.easycfm.com/forums/viewmessages.cfm?Forum=27&Topic=13973