Rudimentary support for table prefixing #1
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
nbproject/
|
||||||
|
.idea/
|
||||||
@@ -57,6 +57,10 @@ class Wrapper{
|
|||||||
|
|
||||||
public static function get_table($name){
|
public static function get_table($name){
|
||||||
$instance = self::getInstance();
|
$instance = self::getInstance();
|
||||||
|
echo $instance->_adapter->getConnection()->prefix;
|
||||||
|
if( $instance->_adapter->getConnection()->prefix ){
|
||||||
|
$name = $instance->_adapter->getConnection()->prefix . $name;
|
||||||
|
}
|
||||||
return new Table($name, Array(), $instance->_adapter);
|
return new Table($name, Array(), $instance->_adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ class Wrapper{
|
|||||||
|
|
||||||
public static function exec($sql){
|
public static function exec($sql){
|
||||||
$instance = self::getInstance();
|
$instance = self::getInstance();
|
||||||
|
$sql = preg_replace('/{(.*)}/', "$con->prefix$1", $sql);
|
||||||
$instance->_driver->exec($sql);
|
$instance->_driver->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
use Schema\Wrapper as Wrapper;
|
||||||
|
|
||||||
|
$conn = new PDO("pgsql:dbname=urfat; user=urfat; password=urfat;host=127.0.0.1;port=5432");
|
||||||
|
$conn->prefix = 'urfat_';
|
||||||
|
Wrapper::set_driver($conn);
|
||||||
|
|
||||||
|
$table = Wrapper::get_table('administrativo_pessoa');
|
||||||
|
$table->drop();
|
||||||
Reference in New Issue
Block a user