print div(xhe('p', xhe('strong', 'Data Source is: ') . xhe('em', $data_source)) . xhe('p', xhe('strong', 'Datasource Type is: ') . xhe('em', $data_source_type)), array('class' => 'sub_title')); //******************************************************* // Local Functions //******************************************************* include 'local.func.php'; include 'tests/contact.class.php'; //******************************************************* // Test Directory //******************************************************* $test_dir = dirname(__FILE__) . '/tests'; //******************************************************* // New Data Transaction //******************************************************* $data1 = new data_trans($data_source); $data1->data_debug(true); $data1->set_opt('make_bind_params_refs', 1); //*********************************************************************** // Delete Rows with ID > 5 //*********************************************************************** $strsql00 = 'delete from contacts where id > 5'; qdb_list($data_source, $strsql00); //*********************************************************************** // Messages //*********************************************************************** $no_setup_msg = 'Invalid Setup.'; $no_bind_msg = 'Data Source Type "' . xhe('em', $data_source_type) . '" does not support bind parameters.'; //*********************************************************************** //*********************************************************************** // Begin Tests //*********************************************************************** //***********************************************************************
function qdb_lookup($data_source, $sql, $fields = '', $bind_params = false, $opts = false) { // Check if fields are not specified if ($fields == '') { trigger_error('ERROR: qdb_lookup(): No return fields specified!!'); } // New Data Transaction $data1 = new data_trans($data_source); if (!empty($opts['debug'])) { $data1->data_debug(true); } $data1->set_opt('make_bind_params_refs', 1); // Use Bind Parameters if (is_array($bind_params) && count($bind_params)) { // Prepare Query $prep_status = $data1->prepare($sql); // Execute Query $exec_status = $data1->execute($bind_params); } else { // Execute Query $query_result = $data1->data_query($sql); } // Pull result set $result = $data1->data_assoc_result(); // If result set empty, return false if (count($result) <= 0) { return false; } else { // Multiple fields specified if (is_array($fields)) { $return_vals = array(); foreach ($fields as $index) { if (array_key_exists($index, $result[0])) { $return_vals[$index] = $result[0][$index]; } else { trigger_error("ERROR: qdb_lookup(): Field '{$index}' does not exist in record set!!"); } } } else { if (array_key_exists($fields, $result[0])) { return $result[0][$fields]; } else { trigger_error("ERROR: qdb_lookup(): Field '{$fields}' does not exist in record set!!"); } } } }