connect是一个类变量,也是连接到数据库的对象。我怎样才能获得变量的功能?在Java中我认为它会像this.variable.method();
public function userLoginCh($username, $password, $userId, $address, $birthday)
{
$mdPass = md5($password);
$addRequestString = "INSERT INTO partnerRequest (userId, address, password, birthday) VALUES (:userId, :address, :mdPass, :birthday)";
$addRequestQuery = $this->connect->prepare($addRequestString);
$addRequestQuery->bindParam(':userId', $userId);
$addRequestQuery->bindParam(':address', $address);
$addRequestQuery->bindParam(':mdPass', $mdPass);
$addRequestQuery->bindParam(':birthday', $birthday);
}
答案 0 :(得分:0)
易:
$this->variable->function();
好的,让我们添加一个例子:
class A {
function say_hi() {
echo 'Hi!';
}
}
class B {
private $class_a;
function __construct() {
$this->class_a = new A;
}
function say_what_a_says() {
$this->class_a->say_hi();
}
}
$b = new B;
$b->say_what_a_says(); // prints out: Hi!