From 2c22fe3f257212efb1ebeb07907cd86431319de1 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sat, 23 Nov 2013 18:22:54 +0200 Subject: [PATCH] Code style and docs at "yii\sphinx\*" fixed. --- extensions/sphinx/ActiveQuery.php | 18 ++++++++++++++++-- extensions/sphinx/ActiveRecord.php | 4 ++-- extensions/sphinx/Schema.php | 7 +------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/extensions/sphinx/ActiveQuery.php b/extensions/sphinx/ActiveQuery.php index a196b56..c56ea2b 100644 --- a/extensions/sphinx/ActiveQuery.php +++ b/extensions/sphinx/ActiveQuery.php @@ -67,15 +67,29 @@ class ActiveQuery extends Query implements ActiveQueryInterface public $sql; /** - * Sets the [[snippetCallback]] to [[fetchSnippetSourceFromModels]], which allows to + * Sets the [[snippetCallback]] to [[fetchSnippetSourceFromModels()]], which allows to * fetch the snippet source strings from the Active Record models, using method * [[ActiveRecord::getSnippetSource()]]. + * For example: + * + * ~~~ + * class Article extends ActiveRecord + * { + * public function getSnippetSource() + * { + * return file_get_contents('/path/to/source/files/' . $this->id . '.txt');; + * } + * } + * + * $articles = Article::find()->snippetByModel()->all(); + * ~~~ + * * Warning: this option should NOT be used with [[asArray]] at the same time! * @return static the query object itself */ public function snippetByModel() { - $this->snippetCallback(array($this, 'fetchSnippetSourceFromModels')); + $this->snippetCallback([$this, 'fetchSnippetSourceFromModels']); return $this; } diff --git a/extensions/sphinx/ActiveRecord.php b/extensions/sphinx/ActiveRecord.php index a59c065..d83db62 100644 --- a/extensions/sphinx/ActiveRecord.php +++ b/extensions/sphinx/ActiveRecord.php @@ -361,9 +361,9 @@ abstract class ActiveRecord extends Model * (because another user has modified the data), a [[StaleObjectException]] exception will be thrown, * and the update or deletion is skipped. * - * Optimized locking is only supported by [[update()]] and [[delete()]]. + * Optimistic locking is only supported by [[update()]] and [[delete()]]. * - * To use optimized locking: + * To use optimistic locking: * * 1. Create a column to store the version number of each row. The column type should be `BIGINT DEFAULT 0`. * Override this method to return the name of this column. diff --git a/extensions/sphinx/Schema.php b/extensions/sphinx/Schema.php index 242752c..6c9571c 100644 --- a/extensions/sphinx/Schema.php +++ b/extensions/sphinx/Schema.php @@ -317,13 +317,8 @@ class Schema extends Object if (!is_string($str)) { return $str; } - $this->db->open(); - if (($value = $this->db->pdo->quote($str)) !== false) { - return $value; - } else { // the driver doesn't support quote (e.g. oci) - return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'"; - } + return $this->db->pdo->quote($str); } /**