Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JOIN support #11

Open
bggardner opened this issue Sep 30, 2014 · 0 comments
Open

JOIN support #11

bggardner opened this issue Sep 30, 2014 · 0 comments

Comments

@bggardner
Copy link
Owner

The Google Visualization Query language does not support JOINs, and I am not currently planning to implement JOINs in google-visualization-php. However, JOINs can be accomplished with a little more leg work using one of these work-arounds:

  • Server-side in SQL:
    • Create a SQL View that performs any necessary JOIN(s) and pass the name of the view to xxxDataSourceHelper instead of a table name.
    CREATE VIEW `report` AS SELECT * FROM `scores` JOIN `people` ON `scores`.`person` = `people`.`id`
  • Server-side in PHP:
    • Execute the JOIN in SQL, then apply the Google Query to the entire data set.
public function generateDataTable(Google\Visualization\DataSource\Query $query)
{
  $pdo = new PDO("mysql:host=xxx;port=xxx;dbname=xxx", "username", "password");
  $stmt = $pdo->query("SELECT * FROM `table1` JOIN `table2` ON `table1`.`col` = `table2`.`col`");
  $dataTable = Google\Visualization\DataSource\Util\Pdo\MySqlPdoDataSourceHelper::buildTable($stmt);
  return Google\Visualization\DataSource\DataSourceHelper::applyQuery($query, $dataTable, Locale::getDefault());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant