Table Functions — This section describes functions which are performed on MAPI Table objects.
array mapi_table_queryallrows(mapitable $table,
array $tagarray,
array $restriction);
array mapi_table_queryrows(mapitable $table,
array $tagarray,
long $start,
long $limit);
long mapi_table_getrowcount(mapitable $table);
boolean mapi_table_sort(mapitable $table,
array $sortcolumns);
boolean mapi_table_restrict(mapitable $table,
array $restriction);
array mapi_table_queryallrows(mapitable $table, array $tagarray, array $restriction)
Queries all the rows in a table and returns a PHP Array
This function reads all the rows of a table and returns the properties specified with the second parameter. Returns an array on success, FALSE on failure. An array with properties that should be queried can be given. Also, an array with restrictions can be given as third argument.
Example 3.40. Reading the rows from a table
// Read the rows with properties PR_ENTRYID and PR_SUBJECT // Restriction which should restrict messages smaller than or equal to 100 bytes $restriction = Array(RES_PROPERTY, Array(RELOP => RELOP_LE, ULPROPTAG => PR_MESSAGE_SIZE, VALUE => array (PR_MESSAGE_SIZE => 100) )); $array = mapi_table_queryallrows($table, array(PR_ENTRYID, PR_SUBJECT), $restriction);
array mapi_table_queryrows(mapitable $table, array $tagarray, long $start, long $limit)
Queries the rows in a table and returns a PHP Array
This function reads at most $limit rows the rows of a table, starting at row $start and returns the properties specified with the second parameter. Returns the array on success, FALSE on failure.
Example 3.41. Reading the rows from a table
// Read the rows with properties PR_ENTRYID and PR_SUBJECT $array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), 10, 10);
long mapi_table_getrowcount(mapitable $table)
Get the amount of rows in a table
Returns the total amount of rows in the table, however, the table may change while processing the rows in the table after retrieving the amount of rows, so you cannot rely on mapi_table_queryrows() to return data for a row which should have existed according to mapi_table_getrowcount(). Returns the amount of rows on success, FALSE on failure.
Example 3.42. Getting the the rows one by one from a table
// Read the rows with properties PR_ENTRYID and PR_SUBJECT for ($i = 0; $i < mapi_table_getrowcount($table); $i++) { $array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), $i, 1); }
boolean mapi_table_sort(mapitable $table, array $sortcolumns)
Sort the given table according to columns.
This function sets the sort order of a table to the given sorting columns. The MAPI provider may or may not actually perform the sort operation at the time of the call, but usually the actual sort is performed when the data is retrieved from the table from mapi_table_queryrows or mapi_table_queryallrows. Returns TRUE on success, FALSE on failure.
Example 3.43. Sorting and retrieving the rows of a table by subject
// Read the rows with properties PR_ENTRYID and PR_SUBJECT mapi_table_sort($table, array(PR_SUBJECT => TABLE_SORT_ASCEND)); for ($i = 0; $i < mapi_table_getrowcount($table); $i++) { $array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), $i, 1); }
boolean mapi_table_restrict(mapitable $table, array $restriction
Restrict the data in a table to certain rules.
This function sets a restriction on the table, narrowing the data in the table.
Example 3.44. Restriction on a mapitable
$restriction = array(RES_CONTENT, array( FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE, ULPROPTAG => PR_SUBJECT, VALUE => array(PR_SUBJECT=>'spam')) ); mapi_table_restrict($table, $restriction); // all mapi_table_queryrows() calls here after only return rows that match the restriction // if the result was false, mapi_last_hresult() will probably be set to MAPI_E_TOO_COMPLEX mapi_table_restrict($table, array()); // this clears the restriction