Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
JDatabaseFactory Usage
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Amy Stephen  
View profile  
 More options Apr 11 2012, 6:13 pm
From: Amy Stephen <amystep...@gmail.com>
Date: Wed, 11 Apr 2012 15:13:22 -0700 (PDT)
Local: Wed, Apr 11 2012 6:13 pm
Subject: JDatabaseFactory Usage

Am I using the JDatabaseFactory, as intended?

1. Get an instance of JDatabaseFactory

$dbFactory = JDatabaseFactory::getInstance();

2. Create a database connection (like JFactory::getDatabase(); does now)

$options = array(
    'driver' => 'mysqli',
    'host' => 'localhost',
    'user' => 'root',
    'password' => 'definitely not root because that would be crazy',
    'database' => 'db_name',
    'prefix' => 'xyz_');

$this->db = $dbFactory->getDriver('mysqli', $options);

Note: $this->db would be stored/retrieved as a static object for later
reuse in queries, etc.

3. Create and use a query object

$this->query = $dbFactory->getQuery('Mysqli', $this->db);

$this->query->from($this->db->qn($this->table_name));

4. Interact with the database object (examples)

 $nullDate = $this->db->getNullDate();

 $columns = $this->db->getTableColumns($this->table_name, false);

$this->db->setQuery($this->query->__toString());

$results = $this->db->loadResult();

Note: these are simply examples -- not intended to be used together.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Amy Stephen  
View profile  
 More options Apr 11 2012, 7:18 pm
From: Amy Stephen <amystep...@gmail.com>
Date: Wed, 11 Apr 2012 16:18:14 -0700 (PDT)
Local: Wed, Apr 11 2012 7:18 pm
Subject: Re: JDatabaseFactory Usage

I am very confused about overlap I see between JDatabaseDriver and
JDatabaseFactory.

These methods are 100% the same code and exist in both classes:
getExporter, getImporter, getQuery.

This method is only in JDatabaseDriver, but I would expect it in
JDatabaseFactory: getIterator.

Is JDatabaseFactory the "entry point" to driver, exporter, importer, query,
and iterator? If so, can we remove the redundant methods from Driver (and
add Iterator to Factory?)

Also - JDatabaseFactory is confusing. It would make more sense (IMO) - if
an instance of JDatabaseFactory were statically made that included the
JDatabaseDriver connection..

So, instead of:

$dbFactory = JDatabaseFactory::getInstance();  //which does nothing really

AND

$options = array(
    'driver' => 'mysqli',
    'host' => 'localhost',
    'user' => 'root',
    'password' => 'definitely not root because that would be crazy',
    'database' => 'db_name',
    'prefix' => 'xyz_');

$this->db = $dbFactory->getDriver('mysqli'
, $options);

If the following were done:

$options = array(
    'driver' => 'mysqli',
    'host' => 'localhost',
    'user' => 'root',
    'password' => 'definitely not root because that would be crazy',
    'database' => 'db_name',
    'prefix' => 'xyz_');

$this->db = JDatabaseFactory::getInstance('mysqli', $options);

Then, $this->db stored as a static instance can then be used for queries,
export, import, and iteration without having to create a new instance each
time.

Does that make any sense? It seems like a cleaner, easier to understand way
to create and reuse a connection to the database, keeping a single point of
entry, and being able to reuse the connection (or create a new one, if
desired.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Amy Stephen  
View profile  
 More options Apr 11 2012, 7:49 pm
From: Amy Stephen <amystep...@gmail.com>
Date: Wed, 11 Apr 2012 16:49:23 -0700 (PDT)
Local: Wed, Apr 11 2012 7:49 pm
Subject: Re: JDatabaseFactory Usage
 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »