I'd like to do a select AS NULL from MySQL db. This is the select query:
function get_new()
{
$query = "SELECT DATE_FORMAT(curdate(),'%d/%m-%Y') AS date_created, NULL AS name, NULL AS address, NULL AS status FROM t_penomoran";
$result = $this->db->query($query)->row();
return $result;
}
This is the controller
public function add()
{
$id = 0;
$master = $this->MPenomoran->get_new();
$data = array (
'titlepage' => APP_TITLEPAGE,
'titleapp' => 'Penomoran',
'userid' => $this->session->userdata('nip'),
'id' => $id,
'record' => $master,
'error' => '',
'complete' => 'true',
'loadmethod' => 'add',
'contentpage' => 'penomoran/detail');
$this->load->view('shared/master_app', $data);
}
And when I use this on the view:
<?php echo $record->name; ?>
I kepp getting Trying to get property of non-object error
. How to solve this?
My table structure:
CREATE TABLE `t_penomoran` (
`nomor` int(50) NOT NULL,
`date_created` date DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
`jenis_pekerjaan` text,
`nominal` bigint(20) DEFAULT NULL,
`address` varchar(50) DEFAULT NULL,
`pic` varchar(100) DEFAULT NULL,
`keterangan` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin