Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL]mysql_insert_id mały klopot
acztery
post
Post #1





Grupa: Zarejestrowani
Postów: 945
Pomógł: 7
Dołączył: 15.03.2005
Skąd: katowice

Ostrzeżenie: (0%)
-----


witam mam taki klopot


  1. public function sqlSave($array,$table,$id='') {
  2. $set = '';
  3.  
  4. while( list($key, $val) = each($array['form'])) {
  5. $set .= '`'.$key.'`=\''. stripslashes($val) .'\', ';
  6. }
  7. $set = substr ($set,0, strlen($set) - 2 );
  8. if (empty($id)) { //insert
  9. mysql_query("INSERT INTO `$table` SET $set");
  10. $id_ = mysql_insert_id();
  11. }
  12. else { //update
  13. mysql_query("UPDATE `$table` SET $set WHERE id = '".$id."'");
  14. $id_ = $id;
  15.  
  16. }
  17.  
  18.  
  19. $cache = new other_cache();
  20. $cache->clearch();
  21. return $id_;
  22. }


i i ta metoda ma zwracac id rekordu dodanego albo edytowanego. (edytowany dziala)
ale mysql_insert_id(); nie dziala

chodzi o zmienną $id_

moze ktos wie o co chodzi
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
acztery
post
Post #2





Grupa: Zarejestrowani
Postów: 945
Pomógł: 7
Dołączył: 15.03.2005
Skąd: katowice

Ostrzeżenie: (0%)
-----


Naspor dzięki.

  1. function m_modules_desc_update($post,$img='')
  2. {
  3.  
  4. if ($img != '')
  5. {
  6. $post['form']['img'] = $this->sqlFiltr($img);
  7. }
  8.  
  9. if ($post['FOR'] != '')
  10. {
  11. $this->sqlQuery("UPDATE modules_desc SET count_mod=count_mod+1 WHERE id='".$this->sqlFiltr($post['FOR'])."'");
  12. $this->sqlSave($post,'modules_desc',$this->sqlFiltr($post['FOR']));
  13. $id=$this->sqlFiltr($post['FOR']);
  14. }else{
  15.  
  16. $prefix = $this->MysqlGetOne("SELECT count(*) FROM modules_desc");
  17. $post['form']['id'] = DoRewrite($post['form']['name'])."_".$prefix;
  18. $post['form']['dateadd'] = date("Y-m-d");
  19. $this->sqlSave($post,'modules_desc');
  20. $id=$post['form']['id'];
  21.  
  22. }
  23. return $id;
  24. }


teraz powinno działać


Jeszcze raz 100 dzięki, nie wiem jak mogłem to przeoczyć....
Masz u mnie piwo.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 9.10.2025 - 03:23