Exemple #1
0
unsigned int Query::Clone(const Query *other)
{
//    TRACE << "Cloning " << other->ToString() << "\n";

    for (restrictions_t::const_iterator i = other->m_restrictions.begin();
	 i != other->m_restrictions.end();
	 ++i)
    {
	if (i->is_string)
	    Restrict(i->which, i->rt, i->sval);
	else
	    Restrict(i->which, i->rt, i->ival);
    }

    for (relations_t::const_iterator i = other->m_relations.begin();
	 i != other->m_relations.end();
	 ++i)
    {
	if (i->anditive)
	    And(Subexpression((int)i->a), Subexpression((int)i->b));
	else
	    Or(Subexpression((int)i->a), Subexpression((int)i->b));
    }

    unsigned int rc = Where(Subexpression(other->m_root));
    if (rc)
	return rc;

    for (orderby_t::const_iterator i = other->m_orderby.begin();
	 i != other->m_orderby.end();
	 ++i)
    {
	rc = OrderBy(*i);
	if (rc)
	    return rc;
    }

    for (orderby_t::const_iterator i = other->m_collateby.begin();
	 i != other->m_collateby.end();
	 ++i)
    {
	rc = CollateBy(*i);
	if (rc)
	    return rc;
    }

//    TRACE << "Cloned: " << ToString() << "\n";

    return 0;
}
Exemple #2
0
 /** expression without query parameters */
 std::string operator()() {      
   return 
     std::string("SELECT ") + 
     //helper::impl_select_part<0,Fields...>()() +
     Fields()() + std::string(" ") + 
     From()() + 
     (std::is_same<Where,none>::value ?
      std::string("") :
      Where()() + 
      (std::is_same<GroupBy,none>::value ?
       std::string("") :
       GroupBy()() + 
       (std::is_same<Having,none>::value ?
        std::string("") :
        Having()()))) +
     (std::is_same<OrderBy,none>::value ? 
      std::string("") : 
      OrderBy()());
 }