Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Can't understand some code in the database class


Recommended Posts



Sorry for duplication of the topic :-)


I've posted the same topic into the forum "In Development / Core Development". But now I think this topic is more related to php programming skills than to a new oscommerce version.


I looked into oscommerce 3.0 a4.

I can't understand a few things in the database class (includes/classes/database.php).


These 2 methods: &connect and &query.


Functions contain "&" before their name.


    function &connect($server, $username, $password, $type = DB_DATABASE_CLASS) {
     require('database/' . $type . '.php');

     $class = 'osC_Database_' . $type;
     $object = new $class($server, $username, $password);

     return $object;

   function &query($query) {
     $osC_Database_Result =& new osC_Database_Result($this);

     return $osC_Database_Result;


But in the includes/application_top.php, where function calls are made, references are not used. "=" sign is used instead of "=&".


// make a connection to the database... now
 $osC_Database = osC_Database::connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);

// set the application parameters
 $Qcfg = $osC_Database->query('select configuration_key as cfgKey, configuration_value as cfgValue
 from :table_configuration');


Why is this? If references are not used in the function calls, why they are used in function definition?




Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...