
3.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 speci-
fied 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 speci-
fied 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! }
3.6. User Integration
VM uses Joomla's user table jos_users for the User Management. Users which are no customers, have just
empty values in their additional customer fields in that table.
There can be users who are no customers, but there can't be customers who are no registered users on the
Joomla Site.
The Shop has an own registration procedure which adds all entries for the additional user fields durch (assigning
the customer to a shopper group, to a vendor...)
VirtueMart Developer Manual
11
Comentários a estes Manuais