MySQL Abfrage - MySQL <-> MySQLi

Alt 04.01.2009, 16:40   # 1
Tobi94b
 
Registriert seit: 11.11.2008
Beiträge: 24
Hallo,
kann mir jemand folgenden Code für mysqli in mysql umschreiben, sodass ich diese Abfrage auch für PHP 4 benutzen kann?

PHP-Code:
  function isDatabaseCleared($id)
  {
    if(
$id>0)
    {
      
// by checking the number of rows with ids smaller than the client's 
      // last id we check to see if a truncate operation was performed in 
      // the meantime            
      
$check_clear 'SELECT count(*) old FROM chat where chat_id<=' $id;
      
$result $this->mMysqli->query($check_clear);
      
$row $result->fetch_array(MYSQLI_ASSOC);      
            
      
// if a truncate operation occured the whiteboard needs to be reset
      
if($row['old']==0)
        return 
'<clear>true</clear>';     
    }
    return 
'<clear>false</clear>';
 
  } 
Vielen Dank und viele Grüße
  Mit Zitat antworten
Alt 17.01.2009, 11:26   # 2
grunzer
Hausmeister im Virtuellen
 
Benutzerbild von grunzer
 
Registriert seit: 28.12.2006
Beiträge: 2.953
Hi,
Du hast recht, daß mysqli nur unter php5 läuft:
Das deutschsprachige PHP Handbuch / Manual bei Dynamic Web Pages! PHP PHP3 PHP4 PHP5 - Deutscher Knotenpunkt fr PHP -> Dynamic Web Pages. Alles zu MySQL, PostgreSQL, XML, Web Services & PHP

Umschreiben will ich nicht.

Es sollte aber recht schnell gehen, wenn Du folgende zwei Befehle ausprobierst:
PHP: mysql_query - Manual
PHP: mysql_fetch_array - Manual

Viel Glück
Grunzer
__________________
Lieber eine unsichere Freiheit
als eine sichere Diktatur !
  Mit Zitat antworten
Alt 21.01.2009, 23:00   # 3
e23
 
Registriert seit: 21.01.2009
Beiträge: 8
...das wird übel. oo-programmierung in php4 ist nicht wirklich toll..
  Mit Zitat antworten
Alt 26.01.2009, 21:54   # 4
leojango
 
Benutzerbild von leojango
 
Registriert seit: 26.01.2009
Ort: Bayern
Beiträge: 9
<?
function isDatabaseCleared($id)
{
if($id>0)
{
// by checking the number of rows with ids smaller than the client's
// last id we check to see if a truncate operation was performed in
// the meantime
$check_clear = "SELECT count(*) old FROM chat where chat_id<=' . $id";
$result = mysql_query($check_clear);
$row = mysql_fetch_array($result);


// if a truncate operation occured the whiteboard needs to be reset
if($row['old']==0)
return '<clear>true</clear>';
}
return '<clear>false</clear>';

}
?>

Das müsste so funzen
  Mit Zitat antworten
Alt 29.01.2009, 19:04   # 5
Tobi94b
Threadstarter
 
Registriert seit: 11.11.2008
Beiträge: 24
Vielen Dank erstmal
ich werds ausprobieren, wenn ich Zeit hab
  Mit Zitat antworten

Antwort
Themen-Optionen



Alle Zeitangaben in WEZ +2. Es ist jetzt 21:12 Uhr.