0
因此,我需要從後端檢索數據並逐個回顯屬性。在PHP中從Backendless獲取數據
所以這是我Pasien.php類那裏有setter和getter:
<?php
namespace Hospinet;
class Pasien
{
private $Tgl_Lahir;
private $Tgl_Masuk;
private $Perawatan;
private $No_Kamar;
private $Nama_Pasien;
private $No_Asuransi;
private $Jenis_Asuransi;
private $Jenis_Kamar;
private $Id_RS;
private $Id_Dokter;
private $Id_Pasien;
private $Gender;
public function construct($tgl_Lahir, $tgl_Masuk, $perawatan, $no_Kamar, $nama_Pasien, $no_Asuransi, $jenis_Asuransi, $jenis_Kamar, $id_RS, $id_Dokter, $id_Pasien, $gender) {
$this->Tgl_Lahir = $tgl_Lahir;
$this->Tgl_Masuk = $tgl_Masuk;
$this->Perawatan = $perawatan;
$this->No_Kamar = $no_Kamar;
$this->Nama_Pasien = $nama_Pasien;
$this->No_Asuransi = $no_Asuransi;
$this->Jenis_Asuransi = $jenis_Asuransi;
$this->Jenis_Kamar = $jenis_Kamar;
$this->Id_RS = $id_RS;
$this->Id_Dokter = $id_Dokter;
$this->Id_Pasien = $id_Pasien;
$this->Gender = $gender;
}
public function getTgl_Lahir() {
return $this->Tgl_Lahir;
}
public function setTgl_Lahir($Tgl_Lahir) {
$this->Tgl_Lahir = $Tgl_Lahir;
}
public function getTgl_Masuk() {
return $this->Tgl_Masuk;
}
public function setTgl_Masuk($Tgl_Masuk) {
$this->Tgl_Masuk = $Tgl_Masuk;
}
public function getPerawatan() {
return $this->Perawatan;
}
public function setPerawatan($Perawatan) {
$this->Perawatan = $Perawatan;
}
public function getNo_Kamar() {
return $this->No_Kamar;
}
public function setNo_Kamar($No_Kamar) {
$this->No_Kamar = $No_Kamar;
}
public function getNama_Pasien() {
return $this->Nama_Pasien;
}
public function setNama_Pasien($Nama_Pasien) {
$this->Nama_Pasien = $Nama_Pasien;
}
public function getNo_Asuransi() {
return $this->No_Asuransi;
}
public function setNo_Asuransi($No_Asuransi) {
$this->No_Asuransi = $No_Asuransi;
}
public function getJenis_Asuransi() {
return $this->Jenis_Asuransi;
}
public function setJenis_Asuransi($Jenis_Asuransi) {
$this->Jenis_Asuransi = $Jenis_Asuransi;
}
public function getJenis_Kamar() {
return $this->Jenis_Kamar;
}
public function setJenis_Kamar($Jenis_Kamar) {
$this->Jenis_Kamar = $Jenis_Kamar;
}
public function getId_RS() {
return $this->Id_RS;
}
public function setId_RS($Id_RS) {
$this->Id_RS = $Id_RS;
}
public function getId_Dokter() {
return $this->Id_Dokter;
}
public function setId_Dokter($Id_Dokter) {
$this->Id_Dokter = $Id_Dokter;
}
public function getId_Pasien() {
return $this->Id_Pasien;
}
public function setId_Pasien($Id_Pasien) {
$this->Tgl_Masuk = $Tgl_Masuk;
}
public function getGender() {
return $this->Gender;
}
public function setGender($Gender) {
$this->Gender = $Gender;
}
}
我想這樣的事情在我的index.php
<?php
namespace Hospinet;
use backendless\Backendless;
use backendless\services\persistence\BackendlessDataQuery;
use backendless\model\BackendlesCollection;
use Hospinet\Pasien;
include "backendless/autoload.php";
include "pasien.php";
Backendless::initApp('appid', 'REST key', 'v1');
$Pasien = new Pasien();
$result_collection = Backendless::$Persistence->of("Pasien")->find($data_query_or_relation_depth = null);
print_r($result_collection->getAsArray());
?>
當我運行它,這是我得到的
backendless\model\BackendlessCollection Object
(
[data] => Array
(
[offset] => 0
[data] => Array
(
[0] => Array
(
[Id_Dokter] => C0E0607E
[created] => 1495593955000
[Gender] => L
[ownerId] => [Id_Pasien] => 1
[No_Asuransi] => H259030
[__meta] => {"relationRemovalIds":{},"selectedProperties":["Id_Dokter","created","Gender","ownerId","Id_Pasien","No_Asuransi","Nama_Pasien","No_Kamar","Tgl_Lahir","Perawatan","Jenis_Asuransi","Jenis_Kamar","Id_RS","___class","Tgl_Masuk","updated","objectId"],"relatedObjects":{}}
[Nama_Pasien] => Agustinus Kuncoro
[No_Kamar] => ICU-2
[Tgl_Lahir] => 29 Maret 1979
[Perawatan] => Hijau
[Jenis_Asuransi] => BPJS
[Jenis_Kamar] => ICU
[Id_RS] => 80923920
[___class] => Pasien
[Tgl_Masuk] => 17 Maret 2017
[updated] => 1495594474000
[objectId] => 347D197A-7235-04AB-FF0A-F9D5215F2F00
)
)
[nextPage] => [totalObjects] => 1
)
[stored_next_page_link] =>
)
它的工作原理,但我想要的是單獨打印屬性...東西這樣,當我運行PHP代碼:
Name: Agustinus Kuncoro
Id = 1
Gender = L
我是新來的PHP,所以我真的很困惑,我能在Android中的PHP使用getter什麼樣的?