
Database Structure
9
•
$vmLogger->warning( 'My warning message to the user' ); // Mainly used to trigger warnings
•
$vmLogger->notice( 'My Notice to the user' );
•
$vmLogger->info( 'My informational message to the user' ); // Used to give success messages
•
$vmLogger->debug( 'My debug message to the user' ); // Only displayed when DEBUG is enabled
•
$vmLogger->tip( 'My advice to the user' ); // Used to display Advice messages to the user
2.4. Database Structure
As said before, all Tables used for VM begin with the prefix _vm_. VM doesn't use Joomla core tables
for storing data.
2.5. Database Access
VM uses its own database access class for dealing with the database.
The database class file is
/administrator/components/com_virtuemart/classes/ps_database.php.
This database class extends Joomla's database class (class ps_DB extends database) and provides
additional functions, to be able to use older phpShop code. So this class is just a wrapper class for
Joomla's database object and doesn't open new connections to the database!
• Start a query: call the method query( string $query )
$db->query( 'SELECT email FROM #__users');
• Get the resulting record set: call method next_record( void ):
$db->next_record();
(returns false when no result can be returned or the end of the record set has been reached)
• Fetch the value of an attribute of the record set: method f( string
$nameOfTheAttribute )
$db->f( 'email' );
Alternative: method sf( string $nameOfTheAttribute ) returns the value of
the attribute specified by $nameOfTheAttribute or - when it's not available - the value of
$vars[$nameOfTheAttribute].
• Print (echo) the value of an attribute of the record set: method p( string
$nameOfTheAttribute )
$db->p( 'email' );
Alternative: method sp( string $nameOfTheAttribute ) prints the value of
the attribute specified by $nameOfTheAttribute or - when it's not available - the value of
$vars[$nameOfTheAttribute].
• Get the number of returned records: method num_rows( void ).
if( $db->num_rows() > 0 ) { // we have a record set! }
Comentários a estes Manuais