Exemplo n.º 1
0
$query_with_subselect = 'SELECT * FROM test WHERE test_name IN (' . $sub_select . ')';
// run the query and get a result handler
echo $query_with_subselect . '<br>';
$result = $mdb2->query($query_with_subselect);
$array = $result->fetchAll();
$result->free();
echo '<br>all with subselect:<br>';
echo '<br>drop index (will fail if the index was never created):<br>';
echo Var_Dump($mdb2->manager->dropIndex('test', 'test_id_index')) . '<br>';
$index_def = array('fields' => array('test_id' => array('sorting' => 'ascending')));
echo '<br>create index:<br>';
echo Var_Dump($mdb2->manager->createIndex('test', 'test_id_index', $index_def)) . '<br>';
if ($mdb2_type == 'mysql') {
    $schema->db->setOption('debug', true);
    $schema->db->setOption('log_line_break', '<br>');
    // ok now lets create a new xml schema file from the existing DB
    $database_definition = $schema->getDefinitionFromDatabase();
    // we will not use the 'metapear_test_db.schema' for this
    // this feature is especially interesting for people that have an existing Db and want to move to MDB2's xml schema management
    // you can also try MDB2_MANAGER_DUMP_ALL and MDB2_MANAGER_DUMP_CONTENT
    echo Var_Dump($schema->dumpDatabase($database_definition, array('output_mode' => 'file', 'output' => $mdb2_name . '2.schema'), MDB2_SCHEMA_DUMP_STRUCTURE)) . '<br>';
    if ($schema->db->getOption('debug') === true) {
        echo $schema->db->getDebugOutput() . '<br>';
    }
    // this is the database definition as an array
    echo Var_Dump($database_definition) . '<br>';
}
echo '<br>just a simple delete query:<br>';
echo Var_Dump($mdb2->exec('DELETE FROM numbers')) . '<br>';
// You can disconnect from the database with:
$mdb2->disconnect();
Exemplo n.º 2
0
/**
 * Returns a string, in the form var_dump or print_r would output.
 * @param type $arg
 * @param type $disableXdebug
 * @return type
 */
function pkvardump($arg, $disableXdebug = true) {
  $useVarDump = true;
  $useVarDump = false;
  ini_set('html_errors', 0);
  ini_set('xdebug.overload_var_dump', 0);
  if ($useVarDump) {
    ob_start();
    Var_Dump($arg);
    $vardump = ob_get_contents();
    //Experimenting 6/16 - replacing with ob_end_flush...
    // ob_end_clean();
    ob_end_flush();
  } else {
    $vardump = print_r($arg, true);
  }
  ini_set('xdebug.overload_var_dump', 1);
  ini_set('html_errors', 1);
  return $vardump;
}