Nie wiem jak to ugryzc. Mam taka funkcje:
<?php function carUploadPhoto() { $db =& JFactory::getDBO(); //Handle image class $image = new atompImage(); //path to upload Dir $uploadPath = JPATH_COMPONENT.DS.'uploads/offers/'; if (JRequest::get( 'post' )) { //Files array $file = JRequest::getVar('image', null, 'files', 'array'); //how many arrays //loop arrays for ($i = 0; $i < $sizeofarray; $i++) { //create a new arrays suitable for upload $newarray[$i] = array('name' => $file['name'][$i], 'type' => $file['type'][$i], 'tmp_name' => $file['tmp_name'][$i], 'error' => $file['error]'][$i], 'size' => $file['size'][$i]); //if arrays not empty process { //SET ALL CLASS METHODS $image->setFiles($newarray[$i]); $image->setImagePath($uploadPath); $image->setMaxImageSize('100000'); if (!$image->check()) { $this->msg .= $image->getMessage(); break; } else { //FILE IMAGE NAME $data['image'.$i] = $newarray[$i]['name']; $row_img =& JTable::getInstance('car_ogloszenia_img', 'Table'); if (!$row_img->bind( $data )) { return JError::raiseWarning( 500, $row_img->getError() ); } if (!$row_img->store()) { JError::raiseError(500, $row_img->getError()); } //GET INSERTED ID FOR NEW INSERTION $database =& JFactory::getDBO(); $this->insertedID = $database->insertid(); //SET IMAGE NAME AND UPLOAD $image->setImageName($this->insertedID .'-'. $newarray[$i]['name'] ); if ($image->upload()) { $image->setThumbWidth('120'); //CREATE THUMBNAILS $image->createThumb(); $image->createLightBox(); } $this->msg .= $image->getMessage(); } } //EOF if empty } //EOF for } //EOF post } ?>
tabela1
id image0 image1 image2 image3
tabela2
.. .. . .. . tabela1_id ... ..
Logika jest taka ze odbieram tablice file przerabiam ja, sprawdzam w innej klasie pliki czy sa poprawne i teraz mam problem nie wiem czy jest to sluszne rozumowanie. Wrzucam najpierw pliki do bazy nastepnie pobieram ostatnie ID i wrzucam do drugiej tabeli (tabela1_id). Pliki rowniez nazywam: ostatnie ID - nazwa pliku.
Chodzi o to ze zapytanie do bazy idzie w petli i nie moge pobrac ostaniego ID dla drugiej tabeli. Pliki laduja sie z poprawna nazwa. Moze jakies inne pomysly?