Icon edb_find

Finds a row in a cursor by key, using the active index.

Syntax
edb_find(<CursorHandle>, <KeyValues>,
          [<NearSearch>])

<CursorHandle> =

Handle of cursor returned by edb_execute function

<SearchValues> = Simple array of values, corresponding
to the indexed columns in the active index

<NearSearch> = Perform a near search

Returns
TRUE if successful, or FALSE if there are any errors

Usage
The edb_find function performs a key search on the active index of a cursor. This function can only be used with cursors on directly-opened tables. Please see the edb_prepare function for more information on opening tables directly. The near search parameter will cause the search to search for the specified key, and if it doesn't exist, to position on the next highest key in the active index order.

You can use the edb_setindex to change the active index order for a table cursor.

Warning If the cursor state, retrievable via the edb_state function, is an insert state (EDB_INSERT_STATE) or update state (EDB_UPDATE_STATE), then this function will cause an automatic call to the edb_post function in order to force the cursor into a browse state (EDB_BROWSE_STATE).

<?php

// The following script connects to an ElevateDB
// Server and database, prepares and executes a
// direct table open, sets the active index order,
// and then performs a near find using the edb_find()
// function

$con = edb_connect("type=remote;charset=Ansi;address=127.0.0.1;"+
                   "uid=Administrator;pwd=EDBDefault;database=Test");
if (!$con)
  {
  die("Could not connect: " . edb_errmsg());
  }

$cmd = edb_prepare($con,"customer",EDB_COMMAND_TABLE);
$cursor = edb_execute($cmd);

edb_setindex($cursor,"ByCompany");

edb_find($cursor,array("Diver"),TRUE);
var_dump(edb_getrow($cursor));

edb_disconnect($con);
?>
Image