Open Source Content Management System

midgard_query_builder

  1. Creating new Query Builder object instance
  2. Midgard Query Builder methods
  3. Usage example:
  4. See also

Midgard Query Builder is a special Midgard PHP class which enables developers to optimize SQL queries used in a Midgard application. Query Builder (QB) may be used only with MgdSchema registered types.

Creating new Query Builder object instance

Query Builder is instantiated by giving it the name of the MgdSchema type being queried.

__object midgard_query_builder(string 'MgdSchema class');__

The midgard_query_builder class used to be called MidgardQueryBuilder in the Midgard 1.7 series

Midgard Query Builder methods

Usage example:

<?php
// Instantiate Query Builder for an Article object
$qb = new midgard_query_builder('midgard_article');

// List articles only in topic 123
$qb->add_constraint('topic', '=', 123);

// Run the query
$articles = $qb->execute();

// Show the articles
foreach ($articles as $article)
{
    echo "<h2>{$articles->title}</h2>\n";
}
?>

See also

Designed by Nemein, hosted by Anykey