![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 238 Pomógł: 1 Dołączył: 27.08.2003 Ostrzeżenie: (0%) ![]() ![]() |
Zadaniem kodu jest wyciągnięcie z bazy największy ID z danej tabeli. Funkcje bazy opierająsię na klasie
[php:1:28807af63d] <? $query = "select MAX(id) from tabela"; $db ->query($query); $max= $db-> fetch_row(); $max=$max[0]+1; ?> [/php:1:28807af63d] klasa obsługująca baze (nie wkleiłem tu całej) [php:1:28807af63d] <? class db { var $connect_id; var $db_name; var $query_result; function db($db_host, $db_user, $db_pass, $db_name, $p = true) { if($p == false) { $this -> connect_id = @mysql_connect($db_host, $db_user, $db_pass); } else { $this -> connect_id = @mysql_pconnect($db_host, $db_user, $db_pass); } if($this -> connect_id) { $dbselect = @mysql_select_db($db_name, $this -> connect_id); if(!$dbselect) { $this -> _error('dbselect'); mysql_close($this -> connect_id); return false; } else { $this -> dbname = $db_name; return true; } } else { $this -> _error('connect'); return false; } } function query($query) { $this -> query_result = ''; $start = $this -> _get_time(); $this -> query_result = @mysql_db_query($this -> dbname, $query, $this -> connect_id); if(!$this -> query_result) { $this -> _error('query'); return false; } else { $this -> executed_queries++; $this -> timer += $this -> _get_time() - $start; return true; } } function fetch_row($query_result = '') { $query_result = (empty($query_result)) ? $this -> query_result : $query_result; $array = mysql_fetch_array($query_result, MYSQL_ASSOC); if(!$array) { return false; } else { return $array; } } ?> [/php:1:28807af63d] problem polega na tym, że kod nie wyciąga z bazy nawiększwego ID |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 25.07.2025 - 08:06 |