我有这个问题:
brew install -HEAD valgrind
valgrind: This formula either does not compile or function as expected on macOS
versions newer than El Capitan due to an upstream incompatibility.
Error: An unsatisfied requirement failed this build.
valgrind ls -l
valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory).
您能告诉我将此查询更改为codeigniter活动记录吗?
答案 0 :(得分:0)
首先:
$data = array(
'person_name' => 'Fadilis' ,
'person_gender' => 'Male' ,
'person_address' => 'Jl.kaliurang km 7',
'person_placeofbirth' => 'Solo',
'person_dateofbirth' => '1991-3-24',
'person_religion' => 'islam',
'person_phonenumber' => '08996787262',
'person_email' => 'fadil@gmail.com',
'person_image' => 'fadil.jpg',
'person_status' => 'aktif',
);
$this->db->insert('tbl_person', $data);
第二
INSERT INTO tbl_user (username, password, person_id,role_id)
VALUES ('Fadil', 'polisi',(select person_id FROM tbl_person
where person_name = 'Fadilis'), (select role_id from ref_role
where role_name = 'admin'));
$select = $this->db->select('select person_id')->from('tbl_person')->where('person_name', 'Fadilis');
$select2 = $this->db->select('select role_id')->from('ref_role')->where('role_name', 'admin');
$data = array(
'username' => 'Fadil' ,
'password' => 'polisi' ,
'person_id' => $select->result_array(),
'role_id' => $select2->result_array()
);
$this->db->insert('tbl_user', $data);
通过这个例子你可以做第三个,这是连接sintaxis:
$this->db->select('*');
$this->db->from('blogs');
$this->db->join('comments', 'comments.id = blogs.id');
$query = $this->db->get();
您应该阅读文档文档: https://www.codeigniter.com/userguide2/database/active_record.html