Firefox 3
Quick navigation:


Returns whole first record for which $equation is met. If $otherFieldname is given, only value of this field is returned.


$var = ptb_map($database, $equation[, $otherFieldname]);

Syntax description

variable containing connected database
condition upon which record should be selected, in the form 'fieldname' == 'value'
optional: name of other field, which value you look for


This function returns array or, if $otherFieldname was given, string. If nothing was found, null is returned.


$x = ptb_map($myDatabase, "'id' == 5", 'age');

The above example finds value of age field of the record, for which id field equals to 5.

This function is useful, when you know value of id (usually as $_GET['id']) and want to find value of other field of this particular record. Notice that you can't just use id as the number of the record in the database (precisely speaking, you could try to use id-1 as this number), since ids will not always be consecutive natural numbers (could be sorted, deleted etc.).

Update: if id is your primary key, it's much faster and convenient to use ptb_connect with id as $keyField–this way you won't need to use ptb_map at all!

ptb_map is faster then ptb_select with $limit 1.