[eluser]Sein Kraft[/eluser]
It doesn't work :S
Quote:Fatal error: Call to undefined method CI_DB_my::num_rows() in E:\server\htdocs\libelula\system\application\models\model_imageboard.php on line 48
I need the id of the latest record to insert in another table.
When I upload a image i assign an id (auto-increment in sql), then i need retrieve that id and insert in other table where the id is inserted with a tag system.
For Example:
I have a form with two inputs, one for the file and other for the tags who represent the image.
For the first instance I insert in the table (images) the data of the uploaded image.
Next I need retrieve the id of the uploaded image from the table (images) and get the tags from the second input of the form and save in the table (tags).
Code:
function insert($data)
{
//INSERT IMAGE IN IMAGES
$user_id = '1';
$user_ip = '127.0.0.1';
$file_hash = 'myhash';
$file_name = $data['file_name'];
$file_ext = $data['file_ext'];
$file_size = $data['file_size'];
$file_width = $data['file_width'];
$file_height = $data['file_height'];
$file_source = $data['file_source'];
$file_tag = $data['file_tag'];
$data = array(
'id' => 'NULL' ,
'user_id' => $user_id,
'user_ip' => $user_ip,
'file_name' => $file_name,
'file_hash' => $file_hash,
'file_ext' => $file_ext,
'file_size' => $file_size,
'file_height' => $file_height,
'file_width' => $file_width,
'file_source' => $file_source
);
$this->db->insert('images', $data);
//INSERT TAGS
$query = $this->db
->select('id')
->from('images')
->limit(1)
->order_by('id','desc');
$data = array(
'image_id' => $query ,
'image_tag' => $file_tag
);
$this->db->insert('tags', $data);
}
Function id() is a test function because I can't do this work.