如何将Php对象转换为字符串?
我正在使用codeigniter从数据库中获取字符串,我想将数据库Postgres中的对象转换为字符串,我应该怎么做如何将Php对象转换为字符串?,php,postgresql,codeigniter,Php,Postgresql,Codeigniter,我正在使用codeigniter从数据库中获取字符串,我想将数据库Postgres中的对象转换为字符串,我应该怎么做 public function gettable($username, $password){ $cek_user = $this->db->query("SELECT hak_akses FROM tablelogin WHERE username = '$username' AND password = md5('$password')"); // Ce
public function gettable($username, $password){
$cek_user = $this->db->query("SELECT hak_akses FROM tablelogin WHERE username = '$username' AND password = md5('$password')"); // Cek User Sudah Terdaftar
if($cek_user->num_rows()>0){
static $cek;
foreach($cek_user->result() as $cek){
$cek->hak_akses;
}
if($cek=='admin'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin'");
return $ambil->result();
}
if($cek=='semi_admin'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin' and table_name != 'Film' and table_name != 'Hewan'");
return $ambil->result();
}
if($cek == 'user'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin' and table_name != 'Gudang' and table_name != 'inventaris' and table_name != 'Pegawai'");
return $ambil->result();
}
}
else {
$hasil = null;
}
}
谢谢你的帮助。我想你想比较一下
$cek->hak_-akses代码>与admin
或semi\u admin
等一起使用。不需要转换为字符串。使用row()
结果集。并使用else if
语句。如下
if($cek_user->num_rows()>0){
$row = $cek_user->row();
$cek = $row ->hak_akses;
if($cek=='admin'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin'");
return $ambil->result();
}
else if($cek=='semi_admin'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin' and table_name != 'Film' and table_name != 'Hewan'");
return $ambil->result();
}
else if($cek == 'user'){
$ambil = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema='public' and table_name != 'tablelogin' and table_name != 'Gudang' and table_name != 'inventaris' and table_name != 'Pegawai'");
return $ambil->result();
}
}
else {
$hasil = null;
}