Ruckusing_Adapter_PgSQL_Base::schema PHP Method

schema() public method

NOTE: this does NOT include any INSERT statements or the actual data
public schema ( string $output_file ) : integer | FALSE
$output_file string the filepath to output to
return integer | FALSE
    public function schema($output_file)
    {
        $command = sprintf("pg_dump -U %s -Fp -s -f '%s' %s --host %s", $this->db_info['user'], $output_file, $this->db_info['database'], $this->db_info['host']);
        return system($command);
    }

Usage Example

 /**
  * test if we can dump the current schema
  */
 public function test_can_dump_schema()
 {
     $this->adapter->execute_ddl('DROP TABLE IF EXISTS "animals"');
     $this->adapter->execute_ddl("CREATE TABLE animals (id serial primary key, name varchar(32))");
     $this->adapter->execute_ddl("CREATE INDEX idx_animals_on_name ON animals(name)");
     $file = RUCKUSING_BASE . '/tests/logs/schema.txt';
     $this->adapter->schema($file);
     $this->assertFileExists($file);
     if (file_exists($file)) {
         unlink($file);
     }
     $this->adapter->execute_ddl('DROP TABLE IF EXISTS "animals"');
 }