Rudimentary support for table prefixing #1

This commit is contained in:
Artur Welp
2019-04-25 05:36:26 -03:00
parent 9f66bb7c55
commit b57229f582
3 changed files with 19 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
nbproject/
.idea/
+5
View File
@@ -57,6 +57,10 @@ class Wrapper{
public static function get_table($name){
$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);
}
@@ -72,6 +76,7 @@ class Wrapper{
public static function exec($sql){
$instance = self::getInstance();
$sql = preg_replace('/{(.*)}/', "$con->prefix$1", $sql);
$instance->_driver->exec($sql);
}
+12
View File
@@ -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();