Browse Source

adjusted elasticsearch and redis AR to use BaseAR

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
ff52f28d0a
  1. 47
      extensions/elasticsearch/ActiveRecord.php
  2. 27
      extensions/redis/ActiveRecord.php

47
extensions/elasticsearch/ActiveRecord.php

@ -10,6 +10,8 @@ namespace yii\elasticsearch;
use yii\base\InvalidCallException; use yii\base\InvalidCallException;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\NotSupportedException; use yii\base\NotSupportedException;
use yii\db\ActiveRecordInterface;
use yii\db\BaseActiveRecord;
use yii\helpers\Inflector; use yii\helpers\Inflector;
use yii\helpers\Json; use yii\helpers\Json;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
@ -42,7 +44,7 @@ use yii\helpers\StringHelper;
* @author Carsten Brandt <mail@cebe.cc> * @author Carsten Brandt <mail@cebe.cc>
* @since 2.0 * @since 2.0
*/ */
class ActiveRecord extends \yii\db\ActiveRecord class ActiveRecord extends BaseActiveRecord
{ {
const PRIMARY_KEY_NAME = 'id'; const PRIMARY_KEY_NAME = 'id';
@ -428,47 +430,4 @@ class ActiveRecord extends \yii\db\ActiveRecord
} }
return $n; return $n;
} }
/**
* @inheritdoc
*/
public static function updateAllCounters($counters, $condition = null, $params = [])
{
throw new NotSupportedException('Update Counters is not supported by elasticsearch ActiveRecord.');
}
/**
* @inheritdoc
*/
public static function getTableSchema()
{
throw new NotSupportedException('getTableSchema() is not supported by elasticsearch ActiveRecord.');
}
/**
* @inheritdoc
*/
public static function tableName()
{
return static::index() . '/' . static::type();
}
/**
* @inheritdoc
*/
public static function findBySql($sql, $params = [])
{
throw new NotSupportedException('findBySql() is not supported by elasticsearch ActiveRecord.');
}
/**
* Returns a value indicating whether the specified operation is transactional in the current [[scenario]].
* This method will always return false as transactional operations are not supported by elasticsearch.
* @param integer $operation the operation to check. Possible values are [[OP_INSERT]], [[OP_UPDATE]] and [[OP_DELETE]].
* @return boolean whether the specified operation is transactional in the current [[scenario]].
*/
public function isTransactional($operation)
{
return false;
}
} }

27
extensions/redis/ActiveRecord.php

@ -292,31 +292,4 @@ class ActiveRecord extends \yii\db\ActiveRecord
} }
return md5(json_encode($key)); return md5(json_encode($key));
} }
/**
* @inheritdoc
*/
public static function getTableSchema()
{
throw new NotSupportedException('getTableSchema() is not supported by redis ActiveRecord.');
}
/**
* @inheritdoc
*/
public static function findBySql($sql, $params = [])
{
throw new NotSupportedException('findBySql() is not supported by redis ActiveRecord.');
}
/**
* Returns a value indicating whether the specified operation is transactional in the current [[scenario]].
* This method will always return false as transactional operations are not supported by redis.
* @param integer $operation the operation to check. Possible values are [[OP_INSERT]], [[OP_UPDATE]] and [[OP_DELETE]].
* @return boolean whether the specified operation is transactional in the current [[scenario]].
*/
public function isTransactional($operation)
{
return false;
}
} }

Loading…
Cancel
Save