コード例 #1
0
 public function testDbMssql()
 {
     include "loader.php";
     require 'unit-tests/config.db.php';
     if (empty($configMssql)) {
         $this->markTestSkipped("Skipped");
         return;
     }
     $connection = new Twm\Db\Adapter\Pdo\Mssql($configMssql);
     //List tables
     $expectedTables = array(0 => 'albums', 1 => 'artists', 2 => 'customers', 3 => 'm2m_parts', 4 => 'm2m_robots', 5 => 'm2m_robots_parts', 6 => 'parts', 7 => 'personas', 8 => 'personnes', 9 => 'prueba', 10 => 'robots', 11 => 'robots_parts', 12 => 'songs', 13 => 'subscriptores', 14 => 'tipo_documento');
     /*		
     		$tables = $connection->listTables();
     		$this->assertEquals($tables, $expectedTables);
     		$tables = $connection->listTables('S_ECSB');
     		$this->assertEquals($tables, $expectedTables);
     		//Table exist
     		$this->assertEquals($connection->tableExists('personas'), 1);
     		$this->assertEquals($connection->tableExists('noexist'), 0);
     		$this->assertEquals($connection->tableExists('personas', 'S_ECSB'), 1);
     		$this->assertEquals($connection->tableExists('personas', 'test'), 0);
     */
     $expectedDescribe = $this->getExpectedColumnsMssql();
     $describe = $connection->describeColumns('personas');
     $this->assertEquals($expectedDescribe, $describe);
     $describe = $connection->describeColumns('personas', 'phalcon_test');
     $this->assertEquals($describe, $expectedDescribe);
     /*
     		//Table Options
     		$expectedOptions = array(
     			'table_type' => 'BASE TABLE',
     			'auto_increment' => NULL,
     			'engine' => 'InnoDB',
     			'table_collation' => 'utf8_unicode_ci',
     		);
     
     		$options = $connection->tableOptions('personas', 'phalcon_test');
     		$this->assertEquals($options, $expectedOptions);
     */
     //Indexes
     $expectedIndexes = array('PRIMARY' => Phalcon\Db\Index::__set_state(array('_indexName' => 'PRIMARY', '_columns' => array('id'))), 'robots_id' => Phalcon\Db\Index::__set_state(array('_indexName' => 'robots_id', '_columns' => array('robots_id'))), 'parts_id' => Phalcon\Db\Index::__set_state(array('_indexName' => 'parts_id', '_columns' => array('parts_id'))));
     /*
     		$describeIndexes = $connection->describeIndexes('robots_parts');
     		$this->assertEquals($expectedIndexes, $describeIndexes);
     $describeIndexes = $connection->describeIndexes('robots_parts', 'phalcon_test');
     		$this->assertEquals($describeIndexes, $expectedIndexes);
     //References
     		$expectedReferences = array(
     			'robots_parts_ibfk_1' => Phalcon\Db\Reference::__set_state(array(
     			'_referenceName' => 'robots_parts_ibfk_1',
     			'_referencedTable' => 'robots',
     			'_columns' => array('robots_id'),
     				'_referencedColumns' => array('id'),
     				'_referencedSchema' => 'phalcon_test'
     			)),
     			'robots_parts_ibfk_2' => Phalcon\Db\Reference::__set_state(array(
     				'_referenceName' => 'robots_parts_ibfk_2',
     				'_referencedTable' => 'parts',
     				'_columns' => array('parts_id'),
     				'_referencedColumns' => array('id'),
     				'_referencedSchema' => 'phalcon_test',
     			)),
     		);
     $describeReferences = $connection->describeReferences('robots_parts');
     		$this->assertEquals($describeReferences, $expectedReferences);
     $describeReferences = $connection->describeReferences('robots_parts', 'phalcon_test');
     		$this->assertEquals($describeReferences, $expectedReferences);
     */
 }
コード例 #2
0
<?php

// Creates the autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array('models/'));
//Register some namespaces
$loader->registerNamespaces(array("twm\\Db\\Adapter\\Pdo" => "adapter/", "twm\\Db\\Dialect" => "dialect/"));
// register autoloader
$loader->register();
echo '<h1>connect</h1>';
$mc = array('host' => 'McDev', 'username' => 'apnewmc', 'password' => 'Cm!2212@12', 'dbname' => 'CCCMCDEV1', 'dialectClass' => '\\Twm\\Db\\Dialect\\Mssql');
$ec = array('host' => 'MSsql', 'username' => 'apedtuser2', 'password' => 'Ecg01dedt', 'dbname' => 'CCCECST2', 'dialectClass' => '\\Twm\\Db\\Dialect\\Mssql');
$db = new \Twm\Db\Adapter\Pdo\Mssql($mc);
if (!$db->connect()) {
    $db->close();
    die('connection failed');
}
//testModel($db);
testQueryBinding($db);
function testModel($db)
{
    $boutique = new Boutique();
}
function testQueryBinding($db)
{
    echo '<h1>execute query</h1>';
    $sqlStatement = "select * from tb_a_boutique_data where 1=':aaa' and 2=':bbb'";
    $bindParams = array(':aaa' => '1', ':bbb' => '2');
    var_dump($db->query($sqlStatement, $bindParams));
}
function testDescribeColumns()