Skip to content

Commit

Permalink
remove default sort and increase randomness of tmp table in join
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranmaher committed Sep 1, 2014
1 parent 705ee35 commit 672e9ea
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,22 @@ class Post extends Eloquent

/**
* Override the default query to do all the category joins
*
*
* @param boolean $excludeDeleted Include soft deleted columns
* @param boolean $setOrderBy By default orders by post_date desc
*
*
* @return object The query object
*/
public function newQuery($excludeDeleted = true, $setOrderBy = true)
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);

$query->where('post_type', $this->postType);
if ($setOrderBy) {
$query->orderBy('post_date', 'desc');
}

return $query;
}

/**
* Define post meta relationship
*
*
* @return object
*/
public function meta()
Expand Down Expand Up @@ -159,7 +154,7 @@ public function formats()
*
* @param object $query The query object
* @param array|string $slug The name(s) of the article(s)
*
*
* @return object The query object
*/
public function scopeSlug($query, $slug)
Expand Down Expand Up @@ -191,7 +186,7 @@ public function scopeId($query, $id)
*
* @param object $query The query object
* @param string $slug The slug name of the category
*
*
* @return object The query object
*/
public function scopeCategory($query, $slug)
Expand All @@ -204,7 +199,7 @@ public function scopeCategory($query, $slug)
*
* @param object $query The query object
* @param string $slug The slug name of the tag
*
*
* @return object The query object
*/
public function scopeTag($query, $slug)
Expand All @@ -231,7 +226,7 @@ public function scopeFormat($query, $slug)
* @param object $query The query object
* @param string $name The taxonomy name
* @param string $slug The slug name
*
*
* @return object The query object
*/
protected function taxonomy($query, $name, $slug)
Expand All @@ -240,7 +235,7 @@ protected function taxonomy($query, $name, $slug)
* The reasoning behind the pre and post fixing is so that a
* category and tag search can be executed at the same time.
*/
$postfix = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 10);
$postfix = substr(str_shuffle(str_repeat('abcdefghijklmnopqrstuvwxyz', 10), 0, 10));
$prefix = $query->getQuery()->getConnection()->getTablePrefix();

$query->select("posts.*")
Expand Down Expand Up @@ -272,7 +267,7 @@ protected function taxonomy($query, $name, $slug)
*
* @param object $query The query object
* @param string $status The status of the post
*
*
* @return object The query object
*/
public function scopeStatus($query, $status = '')
Expand All @@ -282,7 +277,7 @@ public function scopeStatus($query, $status = '')

/**
* Get posts with a given post type
*
*
* @param string $type
* @return \Corcel\PostBuilder
*/
Expand Down

0 comments on commit 672e9ea

Please sign in to comment.