-
Notifications
You must be signed in to change notification settings - Fork 16
Enable MySQL Driver #168
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
Merged
Merged
Enable MySQL Driver #168
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ public function match($str, $limit = 10, $offset = 0) | |
* matchCount | ||
* | ||
* @param string $str | ||
* @return array | ||
* @return int $count | ||
*/ | ||
public function matchCount($str) | ||
{ | ||
|
@@ -127,6 +127,7 @@ public function matchCount($str) | |
WHERE | ||
fts.words MATCH :match | ||
__SQL__; | ||
return \DB::select(\DB::raw($query), array( 'match' => FtsUtils::createMatchWord($str))); | ||
$res = \DB::select(\DB::raw($query), array( 'match' => FtsUtils::createMatchWord($str))); | ||
return $res[0]->count; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. お手数ですがphpdocの |
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php namespace Owl\Repositories\Fluent\MySQL; | ||
|
||
use Owl\Repositories\ItemFtsRepositoryInterface; | ||
use Owl\Libraries\FtsUtils; | ||
use Owl\Repositories\Fluent\AbstractFluent; | ||
|
||
class ItemFtsRepository extends AbstractFluent implements ItemFtsRepositoryInterface | ||
{ | ||
protected $table = 'items'; | ||
|
||
/** | ||
* Get a table name. | ||
* | ||
* @return string | ||
*/ | ||
public function getTableName() | ||
{ | ||
return $this->table; | ||
} | ||
|
||
/** | ||
* get a itemFts by item_id. | ||
* | ||
* @param int $item_id | ||
* @return void | ||
*/ | ||
public function getById($item_id) | ||
{ | ||
return \DB::table($this->getTableName()) | ||
->where($this->getTableName().'.item_id', $item_id) | ||
->first(); | ||
} | ||
|
||
/** | ||
* Create a item fts. | ||
* | ||
* @param int $item_id | ||
* @param string $title | ||
* @param text $body | ||
* @return int | ||
*/ | ||
public function create($item_id, $title, $body) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Convert String into N-Gramed string. | ||
* | ||
* @param string $title | ||
* @param text $body | ||
* @return string | ||
*/ | ||
public function toNgram($title, $body) | ||
{ | ||
return FtsUtils::toNgram($title . "\n\n" . $body); | ||
} | ||
|
||
/** | ||
* Delete a item fts. | ||
* | ||
* @param $item_id int | ||
* @return boolean | ||
*/ | ||
public function deleteItemFts($item_id) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* match | ||
* | ||
* @param string $str | ||
* @param int $limit | ||
* @param int $offset | ||
* @return array | ||
*/ | ||
public function match($str, $limit = 10, $offset = 0) | ||
{ | ||
return \DB::table($this->getTableName()) | ||
->join('users', 'items.user_id', '=', 'users.id') | ||
->where('items.published', '2') | ||
->whereRaw("match(items.title, items.body) against (? in boolean mode)", [$str]) | ||
->select( | ||
'items.title', | ||
'items.updated_at', | ||
'items.open_item_id', | ||
'users.email', | ||
'users.username' | ||
) | ||
->orderBy('items.updated_at', 'desc') | ||
->skip($offset)->take($limit)->get(); | ||
} | ||
|
||
/** | ||
* matchCount | ||
* | ||
* @param string $str | ||
* @return int $count | ||
*/ | ||
public function matchCount($str) | ||
{ | ||
return \DB::table($this->getTableName()) | ||
->join('users', 'items.user_id', '=', 'users.id') | ||
->where('items.published', '2') | ||
->whereRaw("match(items.title, items.body) against (? in boolean mode)", [$str]) | ||
->count(); | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php namespace Owl\Repositories\Fluent\MySQL; | ||
|
||
use Owl\Repositories\TagFtsRepositoryInterface; | ||
use Owl\Libraries\FtsUtils; | ||
use Owl\Repositories\Fluent\AbstractFluent; | ||
|
||
class TagFtsRepository extends AbstractFluent implements TagFtsRepositoryInterface | ||
{ | ||
protected $table = 'tags'; | ||
|
||
/** | ||
* Get a table name. | ||
* | ||
* @return string | ||
*/ | ||
public function getTableName() | ||
{ | ||
return $this->table; | ||
} | ||
|
||
/** | ||
* get a tagFts data or Create a tagFts data by ID and Words. | ||
* | ||
* @param int $tag_id | ||
* @param string $words | ||
* @return array | ||
*/ | ||
public function firstOrCreateByIdAndWords($tag_id, $words) | ||
{ | ||
return array(); | ||
} | ||
|
||
/** | ||
* get a tagFts by tag_id. | ||
* | ||
* @param int $id | ||
* @return void | ||
*/ | ||
public function getById($tag_id) | ||
{ | ||
return \DB::table($this->getTableName()) | ||
->where($this->getTableName().'.tag_id', $tag_id) | ||
->first(); | ||
} | ||
|
||
/** | ||
* get tags data by string for FullTextSearch. | ||
* | ||
* @param string $string | ||
* @param int $limit | ||
* @param int $offset | ||
* @return array | ||
*/ | ||
public function match($str, $limit = 10, $offset = 0) | ||
{ | ||
return \DB::table($this->getTableName()) | ||
->whereRaw("match(tags.name) against (? in boolean mode)", [$str]) | ||
->select( | ||
'tags.name' | ||
) | ||
->orderBy('tags.updated_at', 'desc') | ||
->skip($offset)->take($limit)->get(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍