私はOOPを学んでいます。私の質問は以下のコードに基づいています。値が$query_value->GetName()
または$query_value->GetId()
を使用してindex.phpに返されるたびに、OOPでクエリ値を返す
$query_value
のために毎回MySQLクエリを実行していますか? index.phpの中Class.phpと
<?php
class OOP{
public $name,$id,$password
public function query(){
/* Query Performed
rowCount() = 1 */
$this->name = returned row value;
$this->id = returned row value;
$this->password= returned row value;
return $this; // [NOTE THIS ($this)]
}
public function GetName(){
return $this->name;
}
public function GetId(){
return $this->id;
}
}
で
は
<?php
$test= new OOP();
$query_value = $test->query();
// now returning values
echo $query_value->GetName();
/// Some Html
echo $query_value->GetId();
?>
ありがとうございます!!!!!! –