Example #1
0
 /**
  * Returns the unique rows from a set of rows
  * 
  * @access  public
  * @param   array  $rows rows to process
  * @return  mixed  PEAR_Error on failure, the row array on success
  */
 function unique($rows)
 {
     if (is_array($rows)) {
         $results = array();
         foreach ($rows as $key => $row) {
             if (!isset($current) || $current != $row) {
                 $results[$key] = $row;
                 $current = $row;
             }
         }
         return $results;
     } else {
         return DBA_Table::raiseError('no rows to sort specified');
     }
 }
Example #2
0
// | You should have received a copy of the GNU Lesser General Public     |
// | License along with this library; if not, write to the Free Software  |
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
// | Author: Brent Cook <*****@*****.**>                         |
// +----------------------------------------------------------------------+
//
// $Id: test_table.php,v 1.1 2002/09/24 16:49:26 busterb Exp $
//
// test functionality of the dba table layer
require_once 'DBA/Table.php';
require_once 'DBA/Toolbox.php';
require_once 'hatSchema.php';
$table =& new DBA_Table();
$table->_dateFormat = "M j, Y";
$result = DBA_Table::create('hats', $hatTableStruct, 'file');
if (PEAR::isError($result)) {
    echo $result->getMessage() . "\n";
    exit;
}
// open and close table multiple times while inserting
//foreach (array('w','r') as $mode) {
$mode = 'w';
$result = $table->open('hats', $mode);
if (PEAR::isError($result)) {
    echo $result->getMessage() . "\n";
    exit;
}
echo "Created table 'hats'\n";
for ($i = 0; $i < 2; ++$i) {
    foreach ($hats as $hat) {