togheter and with options...
#1
Posted 03 December 2009 - 06:17 AM
#2
Posted 21 December 2009 - 12:31 PM
skyblaze, on 03 December 2009 - 06:17 AM, said:
anyone?
#3
Posted 22 December 2009 - 03:39 AM
#5
Posted 23 December 2009 - 06:46 AM
Quote
Since together is a method of CActiveFinder, usage should be like this:
Post::model()->findAll('y')->with('x')->together();
#6
Posted 24 December 2009 - 08:24 AM
samdark, on 23 December 2009 - 06:46 AM, said:
Since together is a method of CActiveFinder, usage should be like this:
Post::model()->findAll('y')->with('x')->together();
Yes but i still don't understand the usage of both methods (with() and together()) at the same time
#7
Posted 24 December 2009 - 08:27 AM
#8
Posted 24 December 2009 - 10:04 AM
samdark, on 24 December 2009 - 08:27 AM, said:
Ok so i return to my first question: What is the meaning of:
Post::model()->findAll()->with('Comments')->together()
...knowing that the with() method alone already produce a single join statement?
#9
Posted 25 December 2009 - 03:32 AM
/**
* Uses the most aggressive join approach.
* By default, several join statements may be generated in order to avoid
* fetching duplicated data. By calling this method, all tables will be joined
* together all at once.
* @param boolean whether we should enforce join even when a limit option is placed on the primary table query.
* Defaults to true. If false, we would still use two queries when there is a HAS_MANY/MANY_MANY relation and
* the primary table has a LIMIT option. This parameter is available since version 1.0.3.
* @return CActiveFinder the finder object
* @since 1.0.2
*/
public function together($ignoreLimit=true)
{
$this->joinAll=true;
if($ignoreLimit)
$this->baseLimited=false;
return $this;
}
joinAll is then used in buildQuery() and count().
Try profiling SQL generated when using limit.
So it's to JOIN all tables at once even if there are duplicates.
#10
Posted 25 December 2009 - 11:18 AM
#11
Posted 25 December 2009 - 04:30 PM
samdark, on 25 December 2009 - 03:32 AM, said:
/**
* Uses the most aggressive join approach.
* By default, several join statements may be generated in order to avoid
* fetching duplicated data. By calling this method, all tables will be joined
* together all at once.
* @param boolean whether we should enforce join even when a limit option is placed on the primary table query.
* Defaults to true. If false, we would still use two queries when there is a HAS_MANY/MANY_MANY relation and
* the primary table has a LIMIT option. This parameter is available since version 1.0.3.
* @return CActiveFinder the finder object
* @since 1.0.2
*/
public function together($ignoreLimit=true)
{
$this->joinAll=true;
if($ignoreLimit)
$this->baseLimited=false;
return $this;
}
joinAll is then used in buildQuery() and count().
Try profiling SQL generated when using limit.
So it's to JOIN all tables at once even if there are duplicates.
ok anyway now with() will use a single join by default so we don't have to "force" with toghether to true
#12
Posted 27 December 2009 - 04:29 PM
#13
Posted 27 December 2009 - 11:27 PM
Is it possible to define a default "with"-option? Example:
$items = Posts::model()->mostDiscussed()->with('category')->findAll();I want it like this:
$items = Posts::model()->mostDiscussed()->findAll();
This doesn't work for some reason:
public function defaultScope()
{
return array(
'with' => 'category',
);
}Anyone?

Help
















