Firebird Schema - alpha version

Hi,

I have developed a version of the Yii Database Schema for Firebird.

The work has been based on PostgreSQL schema.

Until now the Schema is able to SELECT, but some features like applyLimit are still not working, and no INSERT, UPDATE or DELETE is working, because of a PDO bug.

The bug is with the Firebird PDO Driver "bindValue" and "bindParam" methods.

So I will have to wait until this bug is fixed to continue the coding.

I still need to optimize some SQLs and test with all data types available.

Below you will find a list of the changes I did and attached are the 4 files.

  1. /framework/db/CDbConnection.php -> getSchema()

switch(strtolower($driver))

{

case 'firebird':  // Firebird


	return $this->_schema=new CFirebirdSchema($this);
  1. /framework/db/YiiBase.php

private static $_coreClasses=array(

'CFirebirdColumnSchema' => '/db/schema/firebird/CFirebirdColumnSchema.php',


'CFirebirdCommandBuilder' => '/db/schema/firebird/CFirebirdCommandBuilder.php',


'CFirebirdSchema' => '/db/schema/firebird/CFirebirdSchema.php',


'CFirebirdTableSchema' => '/db/schema/firebird/CFirebirdTableSchema.php',
  1. /framework/db/schema/firebird

CFirebirdColumnSchema.php

CFirebirdCommandBuilder.php

CFirebirdSchema.php

CFirebirdTableSchema.php

  1. IMPORTANT NOTICEs

a) PHP 5.2.10 is mandatory because of the following bug:

http://bugs.php.net/bug.php?id=47845

B) Firebird PDO “bindValue” or “bindParam” do not work if we use “:parameter”,

but do work if we use "?".

I have reported this error to PHP.NET:

http://bugs.php.net/bug.php?id=48877

"bindValue" and "bindParam" do not work for PDO Firebird

Although I’m not going to make use of this add-on, I think your contribution is really appreciated!

Great job! When the bugs that you mentioned are fixed by PHP, we can include your work into our core framework. Thank you very much!

I will try to finish it as soon as possible :slight_smile:

I am currently testing the model/crud generation from command line, but there is a weird error.

When I call:

yiic.php webshell

using a Firebird connection the PDO object is not created at the following method (I have printed the parameters and all are OK):

protected function createPdoInstance()


{


	$pdoClass='PDO';


	if(($pos=strpos($this->connectionString,':'))!==false)


	{


		$driver=strtolower(substr($this->connectionString,0,$pos));


		if($driver==='mssql' || $driver==='dblib')


			$pdoClass='CMssqlPdoAdapter';


	}

echo $this->connectionString;

echo "\n";

echo $this->username;

echo "\n";

echo $this->password;

echo "\n";

print_r($this->_attributes);

echo "\n";

	return new $pdoClass($this->connectionString,$this->username,


								$this->password,$this->_attributes);


}

But if I call the application with a Firebird connection and using models/crud generated with a MySQL connection, the same method works fine.

If I use MySQL everything works fine.

Is there anything I have to configure in "yiic.php" to recognize Firebird from command prompt.

Thanks

Hi!

Firebird.zip -> File not found.

How can I get it?

Hi,

I am posting the files again:

  1. /framework/YiiBase.php

private static $_coreClasses=array(

‘CFirebirdColumnSchema’ => ‘/db/schema/firebird/CFirebirdColumnSchema.php’,

‘CFirebirdCommandBuilder’ => ‘/db/schema/firebird/CFirebirdCommandBuilder.php’,

‘CFirebirdSchema’ => ‘/db/schema/firebird/CFirebirdSchema.php’,

‘CFirebirdTableSchema’ => ‘/db/schema/firebird/CFirebirdTableSchema.php’,

  1. /framework/db/CDbConnection.php -> getSchema()

switch(strtolower($driver))

{

case ‘firebird’: // Firebird

return $this->_schema=new CFirebirdSchema($this);

  1. /framework/db/schema/firebird

CFirebirdColumnSchema.php

CFirebirdCommandBuilder.php

CFirebirdSchema.php

CFirebirdTableSchema.php

Siegmar

274

firebird.zip

Notice: "Fatal error: Call to a member function setAttribute() on a non-object in D:\yii\framework\db\CDbConnection.php on line 294" could be caused by backslashes in DSN "connectionString". Always use forward slashes, even on Windows.

CFirebirdSchema.php "(a.rdb$relation_name=\’’.$table->name.’\’)’; " doesnt work last row in where condition.

"a.rdb" change to "c.rdb" then its working.


protected function findConstraints($table)

    {

        $sql = 'SELECT

                    c.rdb$relation_name AS ftable,

                    d.rdb$field_name AS ffield,

                    e.rdb$field_name AS lfield

                FROM

                    rdb$ref_constraints b,

                    rdb$relation_constraints a,

                    rdb$relation_constraints c,

                    rdb$index_segments d,

                    rdb$index_segments e

                WHERE

                    (a.rdb$constraint_type=\'FOREIGN KEY\') AND

                    (a.rdb$constraint_name=b.rdb$constraint_name) AND

                    (b.rdb$const_name_uq=c.rdb$constraint_name) AND

                    (c.rdb$index_name=d.rdb$index_name) AND

                    (a.rdb$index_name=e.rdb$index_name) AND

                    (a.rdb$relation_name=\''.$table->name.'\')'; 

Are there any news about bindValue or bindParam ???

i get follow errors with bindParam;

" CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: -151 attempted update of read-only column",

"CDbCommand failed to prepare the SQL statement"

Hi.

The bug in BindValue or BindParam will be closed in PHP 5.3.9 and 5.4.