mfcdb_exists

Verify if a record exists in a table


Prototype:

boolean mfcdb_exists( resource $resource, string $key [, int $key_number ] )




The function verify if a record exists in a table. The record is pointed by $key and the table is identified by $resource. An optional argument $key_number forces the search on a specified key (0…n) where value 0 is PRIMARY KEY.

RETURN: The function returns TRUE if record exists or FALSE.

Example

<?php
$resource = mfcdb_open("mydatabase");
 
if($resource == FALSE) {
  die("An error occurred opening table, error is: ".mfcdb_error()."\n");
}
 
$key = "42";
if(mfcdb_exists($resource, $key)) {
  echo "The record with key :".$key." exists\n";
} else {
  echo "The record with key :".$key." not exists\n";
}
 
if(mfcdb_close($resource) == FALSE) {
  die("An error occurred closing table, error is: ".mfcdb_error()."\n");
}
 
?>
documentation/mfcdb_exists.txt · Ultima modifica: 2008/08/22 23:11 da gchiesa