EllisLab text mark
Advanced Search
1 of 2
1
   
Firebird Driver Finally!!
Posted: 21 October 2010 01:59 AM
Avatar
Joined: 2009-02-24
20 posts

I have developed a FirebirdDB driver for Codeigniter 2.0 +

you can get it at GitHub here: [url=https://github.com/cgarciagl/Firebird-for-Codeigniter[/url]

**moved to GitHUB**

feel free to provide feedback smile

Cheers

 Signature 

——————————-
My Blog in Spanish

 
Posted: 21 October 2010 02:46 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-28
148 posts

Excellent Carlos.

Felicidades Carlos en lo particular no he usado mucho Interbase o Firebird, pero por cuestiones de trabajo hace casi un año que tengo que administrar una base de datos de firebird, así que abra que probar este driver. Gracias por el aporte.

 Signature 

Enough work has cost to me commit my sins
To devalue them in vain regrets.

 
Posted: 21 October 2010 03:12 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-10
2939 posts

Good work man. Your efforts are much appreciated.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

 
Posted: 22 October 2010 11:39 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-17
74 posts

It’s been more than 2 years since the last time I had to work with a Firebird database… And now I’ll be required to use it again for a new project.

Just in time. Gracias Carlos!

 Signature 

janogarcia.es, @janogarcia
margenn - web studio, San Sebastian (Spain) $CI = new $class();

 
Posted: 26 October 2010 04:56 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-16
10 posts

Finally!! My pain is going to end!  LOL

Serious… I have used a modification that I found on the internet that has allowed me to make selects in this database, wich has served me well so far. However, I had now to write some code to make insertions and it isn’t working. Will this driver of yours work on CI 1.72 or it is designed for 2.0 only? By the way, when this new version will ever be launched anyway?

Thanks for the help.

 
Posted: 27 October 2010 02:28 AM   [ # 5 ]   [ Rating: 0 ]
Joined: 2010-10-27
1 posts

Thank you Carlos i would try it and let you know about it as of in searching of this so long.

 
Posted: 27 October 2010 02:42 PM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-16
10 posts

Hey guys! What’s up?

Carlos, I have updated the driver of my application with yours and guess what? It works!  cheese Thank you for the good work!!

However, I’m having throuble with blob type fields. The select returns a strange data like “0x000000170000029e”, instead of my saved text.

Can you help me?

Thanks.

 
Posted: 27 October 2010 03:45 PM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-24
20 posts
Capt. Kirk - 27 October 2010 06:42 PM

Hey guys! What’s up?

Carlos, I have updated the driver of my application with yours and guess what? It works!  cheese Thank you for the good work!!

However, I’m having throuble with blob type fields. The select returns a strange data like “0x000000170000029e”, instead of my saved text.

Can you help me?

Thanks.

Glad to hear that it works for you grin

could you provide a test case for this issue?? Firebird Version and the type and subtype of the blob field ??

 Signature 

——————————-
My Blog in Spanish

 
Posted: 27 October 2010 04:10 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-16
10 posts

Firebird 2.1.2
Blob field = MESS_TEXTO BLOB SUB_TYPE 1 CHARACTER SET NONE

if (!isset($_POST['mess_id'])):
  
$result $this->mensagens_model->recupera_mensagem($id);
  foreach (
$result->result() as $row):
    foreach (
$row as $field => $value):
      if (
is_date($value)):
        
$_POST[strtolower($field)dtoc($value);
      else:
        
$_POST[strtolower($field)$value;
      endif;
    endforeach;
  endforeach;
endif;

print_r($_POST);

Array
(
    
[mess_id] => 12
    [mess_destinatario_codigo] 
=> AL     
    [mess_destinatario_nomefant] 
=> Alagoas
    [mess_data_entrega] 
=> 27/10/2010
    [mess_tipo] 
=> E
    [mess_natureza] 
=> Promoção
    [mess_duracao] 
=> 2
    [mess_notificacao] 
=> 0
    [mess_notifica_email] 
=> 
    
[mess_imagem] => 
    
[mess_texto] => 0x000000150000029e  <- This the Blob field
 
Posted: 28 October 2010 02:09 AM   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-24
20 posts

Hi, i’ve updated the driver in bitbucket with a new function to get the blob content of a field.

You just have to pass to the new function the content that is returning now in your field and it will return the real content of the field, in your case with something like this:

echo $this->db->get_blob($_POST[mess_texto]); 

so, update the driver and hope this works for you wink

 Signature 

——————————-
My Blog in Spanish

 
Posted: 28 October 2010 03:38 PM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-16
10 posts

Hey Carlos! What’s up?  grin

Thanks man! It worked just fine. Good job!

See ya.

 
Posted: 29 October 2010 09:56 AM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2006-05-20
147 posts

Hi Carlos,  thanks for doing this.  We really need it.

I’ve been using Firebird since 2006 with CI, but never used the native CI libraries for this because of poor performance.  The CI libraries, from what I’ve seen and from a cursory review of your code as well, uses the COUNT(*) command to determine max number of rows so that pagination can be supported.  This works great in MySQL but in Firebird as you probably know, as is the case with any other version supported database, is really bad in performance.

I took a quick look at your code and I see that you are using the COUNT(*) basis for this with queries, and I suspect you’ll encounter the very same issues I found with this - queries are REALLY slow for large table sets.  I’m not sure what the answer is to address this, but I ended up writing an entire separate library based on some existing code, and with the help of Firebird expert Alan McDonald, to do this that is based around the EZSql code libraries, and since pretty much all of my queries are done to stored procedures, I can get this to work fine for performance.

I’m not sure if you have any ideas of how to get around avoiding using COUNT(*) altogether, but I think its needed if this is to perform with larger data sets (ie. more than 20,000 rows in a query).

Thoughts?

Myles

 Signature 

Myles Wakeham
CTO/CEO
Arizona Web Developers Edgeneering, LLC
Podcast Hosting at CyberEars.com
Follow Me on Twitter!

 
Posted: 20 March 2012 02:05 PM   [ # 12 ]   [ Rating: 0 ]
Joined: 2012-03-20
2 posts

Hi,

Can you update the source code with changes below?
I just fix the code for “num_rows()” function on the “firebird_result.php”.
I think because “ibase_num_rows” does not exists, o function was implemented to return always TRUE, see the code below:

function num_rows()
{
     
return  TRUE;  //ibase_num_rows($this->result_id);


As I need this function working, I did a fix for it, see the code:

function num_rows()
{
     $i 
0;
     while (
$row = @ibase_fetch_object($this->result_id)) {
          $i
++;
     
}
     
return $i;

Thanks a lot,

Fábio R. Bot Silva.
KeyCode Tecnologia.

 

 
Posted: 20 March 2012 03:24 PM   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-24
20 posts

Hi Fábio !!!

i have tried that to get the num_rows, but the problem is that once the num_rows function is called i can’t reset the pointer of the resultset to the first record again, so when you use ActiveRecord the querys always are returned as empty :( ...

the only solution is to run twice the query, once to get the number of records of the resultset and another to get the resultset itself :( as in this example:
http://www.php.net/manual/es/function.ibase-fetch-row.php#33820

i dont want to run twice the query so, i’m still thinking and waiting for a better solution for that problem… any help about it is very welcome smile


by the way i’ve moved the project to GitHub where i’m mantaining some other projects at this address:

https://github.com/cgarciagl/Firebird-for-Codeigniter

Thanx

 Signature 

——————————-
My Blog in Spanish

 
Posted: 21 March 2012 08:10 AM   [ # 14 ]   [ Rating: 0 ]
Joined: 2012-03-20
2 posts

Hi Carlos,

You’re right, unfortunatelly the record pointer advances and a new and undesirable fetch will become necessary.

At the application model, I’m doing some simulations to get records count with:

num count($query->row_array()); 

It seems to work right for while.

About num_rows(), I’m trying to get the original “SQL SELECT statement” from the query, and then do a new query over that for count, something like this:

“SELECT 1 FROM (SELECT statement)” and then count the result set on a loop.

I can’t use “SELECT COUNT(*) FROM (SELECT statement)” because COUNT(*) isn’t eficient and can cause an overhead.

I’m doing some tests and if I reach an acceptable solution I will tell you.

Thanks,

Fábio R. Bot Silva.
KeyCode Tecnologia.

 
Posted: 23 April 2012 12:55 PM   [ # 15 ]   [ Rating: 0 ]
Joined: 2012-04-23
2 posts

Buenos días! Goof morning!

Alguien podria ayudarme? /Someona can help me?

Me arroja: /Throws me:

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: C:\xampplite\htdocs\org\sitis\save\system\database\DB_driver.php

Line Number: 124


En el PHP.ini tengo habilitada: / In the PHP.ini have:

extension=php_interbase.dll

Mi database.php tiene: /My database.php have:
$db[‘default’][‘hostname’] = “10.50.1.204”;
$db[‘default’][‘username’] = “SYSDBA”;
$db[‘default’][‘password’] = “zitiz”;
$db[‘default’][‘database’] = “SAVE”;
$db[‘default’][‘dbdriver’] = “firebird”;
$db[‘default’][‘port’] = 3050;
$db[‘default’][‘pconnect’] = TRUE;
$db[‘default’][‘db_debug’] = TRUE;
$db[‘default’][‘cache_on’] = FALSE;

 
1 of 2
1