PHP Fatal error: Appel à un membre de la fonction ligne() sur un non-objet dans
pouvez vous s'il vous plaît m'aider avec mon code, je suis nouveau en php et codeigniter, j'essaie d'obtenir le résultat de ma requête à la vue, mais c'est toujours une erreur s'est produite "erreur Fatale: Appel à un membre de la fonction ligne() sur un non-objet", iam essayant de trouver un infos client par client id et essayer d'obtenir le résultat de la vue elle-même
c'est afficher le code
<?php echo form_open('home/cari_id');
?>
<table width='34%' align='left'>
<tr>
<td width="54%" align="left">ID Pelanggan</td>
<td width="36%">
<?php echo form_input('id',set_value('id'));?>
<?php echo form_error('id');?>
</td>
<td width="10%">
<?php echo form_submit('submit','Cari');?>
</td>
</tr>
</table>
<br /><br />
<table width="68%" align="left">
<tr>
<td width="17%" align="left">Nama</td>
<td>
<?php
$row = $record->row();
$nama1 = array(
'name' => 'nama',
'maxlength' => '100',
'size' => '50',
'style' => 'width:120%');
echo form_input($nama1,$row->nama);?>
<?php echo form_error('nama');?>
</td>
</tr>
<tr>
<td align="left">Alamat</td>
<td>
<?php
$alamat1 = array(
'name' => 'alamat',
'rows' => '5',
'cols' => '3',
'style' => 'width:200%');
echo form_textarea($alamat1,$row->alamat);?>
<?php echo form_error('alamat');?>
</td>
</tr>
<tr>
<td align="left">Golongan</td>
<td width='29%'>
<?php
$gol1 = array(
'name' => 'gol',
'maxlength' => '100',
'size' => '50',
'style' => 'width:40%');
echo form_input($gol1,$row->golongan);?>
<?php echo form_error('gol');?>
</td>
<td width="10%" align="left">Tarif</td>
<td width="44%">
<?php
$tarif = array(
'name' => 'tarif',
'maxlength' => '100',
'size' => '50',
'style' => 'width:30%');
echo form_input($tarif,$row->tarif);?>
<?php echo form_error('tarif');?>
</td>
</tr>
</table>
voici mon code contrôleur
public function cari_id()
{
$this->auth->restrict();
//mencegah user mengakses menu yang tidak boleh ia buka
$this->auth->cek_menu(4);
$this->load->library('form_validation');
$this->form_validation->set_rules('id', 'ID Pelanggan', 'trim|required');
//$this->form_validation->set_rules('nama','Nama','trim'|'required');
//$this->form_validation->set_rules('alamat','Alamat','trim'|'required');
//$this->form_validation->set_rules('gol', 'Golongan', 'trim|required');
//$this->form_validation->set_rules('tarif', 'Tarif', 'trim|required');
$this->form_validation->set_error_delimiters(' <span style="color:#FF0000">', '</span>');
$id_pel = $this->input->post('id') ;
//$data1 = $this->usermodel->get_list_bayar_pel($id_pel);
//$data=$data1->row();
$data1 = $this->usermodel->get_list_bayar_pel($id_pel);
$data['record'] = $query->result_array();
$this->template->set('title','Input Pembayaran | POS Application');
$this->template->load('template','admin/input_pembayaran',$data);
}
et le modèle de code
function get_list_bayar_pel($id)
{
$this->db->select('b.name as nama, b.address as alamat, c.nm_gol as golongan,d.rate_value as tarif');
$this->db->from('account_t a, account_nameinfo_t b, golongan_t c, (select rate_value from rate_t a, golongan_t b where a.id_gol = b.id_gol) d');
$this->db->where('a.id_account = b.obj_id');
$this->db->where('a.id_gol = c.id_gol');
$this->db->where('a.id_account = "'.$id.'"');
$result = $this->db->get();
return $result;
}
grâce avant
Vous devez vous connecter pour publier un commentaire.
écrire ceci dans votre contrôleur
et en vue de supprimer l'
le code php écrire
dans le modèle
$record n'est pas le retour d'une seule ligne, il est de retour d'une collection use current($dossier)->ligne() ou chercher une seule ligne.
Dans votre contrôleur de l'extraction de plusieurs lignes
Il devrait être
et en vue de donner $row = $record; au lieu de $row = $record->ligne();
En fonction de votre code, vous avez utilisé row() fonction pour la récupération des données dans la vue, en attendant, il a été récupéré dans le contrôleur de l'utilisation de ce :
Suffit d'utiliser l'un d'eux (dans le Contrôleur) :
ou
Et ensuite traiter le tableau dans la vue
Espère que cela aide 🙂
Remarque :
- Je vous recommande d'utiliser result_array() pour récupérer les données dans un tableau