QApplication::Autoload()

thread: 10 messages  |  last: a year ago  |  started: wednesday, december 12, 2007, 3:39 am pst


#1  |  Patrik B (Slovakia) Slovakia
Wednesday, December 12, 2007, 3:39 AM PST

Hi,

I found some issues with QApplication::Autoload() in 0.3.38 (Qcodo Beta 3).

I am not able to use it because it is still trying to load QMySqliDatabase class (i use MySqli adapter).

If i put code below into prepend.inc to QApplication class it outputs QMySqliDatabase but i have no idea why because i can use framework without problems... for example load object from generated class.

public static function Autoload($strClassName) {
     // First use the Qcodo Autoloader
     if( ! parent::Autoload($strClassName)) {
          echo $strClassName;
     }
}

So it looks that QMySqliDatabase class is not loaded via Autoload() but in some other way.

In some of previous versions of QCodo this was working without problems when i've added return true; into QApplicationBase::Autoload() parts (as it is now).

Best regards

Patrik

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Friday, December 14, 2007, 4:45 PM PST

did you do an update to this version of qcodo?

or are you using a fresh install of this version of qcodo?

#3  |  Patrik B (Slovakia) Slovakia
Saturday, December 15, 2007, 10:44 AM PST

Hi Mike,

I've removed everything from previous version, copied new one and just replaced and little bit changed prepend.inc.php and configuration.inc.php with old one.

But i've had this issue also with fresh install on my other project.

Best regards

Patrik

#4  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Monday, December 17, 2007, 6:54 AM PST

You'll want to make sure to do a diff between prepend.inc.php and configuration.inc.php with the newest versions from the distribution version that you're using, and make sure to add any additional logic that is in the newer version.

#5  |  Patrik B (Slovakia) Slovakia
Monday, December 17, 2007, 7:38 AM PST

Hi Mike,

so... it seems that you don't believe me, do you ? :D

anyway, i've took latest release (0.3.42), set DB adapter to MySqli, created needed dirs and set permissions, and I've added echo to Autoload() in prepend.inc.php

                        public static function Autoload($strClassName) {
                                // First use the Qcodo Autoloader
                                if (!parent::Autoload($strClassName)) {
                                        // TODO: Run any custom autoloading functionality (if any) here...
                                        echo $strClassName;
                                }
                        }

and it writes “QMySqliDatabase” on top of every page. Even code generating is ok, but there is “QMySqliDatabase” on codegen page.

#6  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Friday, December 28, 2007, 8:44 PM PST

Not that I don't believe you... it's just that i can't replicate the issue you're getting. =)

What if you did a completely fresh install of qcodo on your local dev box... is it working okay?

#7  |  Ken Hawkins (Atlanta, GA) United States of America
Sunday, December 30, 2007, 1:40 PM PST

Patrik,

If I am understanding correctly your original post

So it looks that QMySqliDatabase class is not loaded via Autoload() but in some other way.

the database loaders are called in 'InitializeDatabaseConnections()' that are a part of the prepend.inc.php;

////////////////////////////////////////////////
// Initialize the Application and DB Connections
////////////////////////////////////////////////
QApplication::Initialize();
QApplication::InitializeDatabaseConnections();

you will see for yourself;

$strDatabaseType = 'Q' . $objConfigArray['adapter'] . 'Database';

if (!class_exists($strDatabaseType)) {
  $strDatabaseAdapter = sprintf('%s/database/%s.class.php', __QCODO_CORE__, $strDatabaseType);

if (!file_exists($strDatabaseAdapter)) {
  throw new Exception('Database Type is not valid: ' . $objConfigArray['adapter']);
  require($strDatabaseAdapter);
}

I myself moved the function from ApplicationBase.class.php into prepend.inc.php so I could overwrite the default Q<databasetype>Server.class.php loading.

of course I am on 0.3.32 and so I hope the particulars of the upgrade are basically the same.

hopefully this helps!

ken;

#8  |  Alvaro Linares (Buenos Aires, AR) Argentina
Friday, January 4, 2008, 10:05 AM PST

Hi!!!
I gess I've found the mistake.

Calling class_exists($strDatabaseType) without 2nd parameter in false (takes true as default) makes clasS_exists function to try to load through __autoload declared function (in this case Application::Autoload($strclassname))

I've found it because an error I had using PostgresQL driver, it looks like is always using a generic way of querying, and when it has to do something particular for a specific database engine it blows up.

Ok, so, this is the way I've fixed it, and wanted to tell Mike to have it a look, cause reading the code, I think this is the spected behaviuor:


if (!class_exists($strDatabaseType, false)) {

Saludos, have a great new year you all.

Alvaro

#9  |  Patrik B (Slovakia) Slovakia
Sunday, January 6, 2008, 4:36 PM PST

Happy new year everybody and thanks for your posts ;)

Alvaro i did not try it yet, but according to your and Ken's post this looks like our issue.

Many thanks to all for troubleshooting ;)

Patrik

#10  |  Muthu kumar (India) India
Thursday, June 17, 2010, 1:59 AM PDT

you don't want to update your version.

For auto load functions

protected function Form_Exit() {          
           // _p(“<script>document.getElementById('”.$this->txtCustomerName->ControlId.”').focus();</script>”,false) ;    
           $this->txtCustomerName->Focus();
           QApplication::ExecuteJavaScript(“alert('hi')”);
       }



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.