Skip to content

Instantly share code, notes, and snippets.

@jkovacs618
jkovacs618 / Extended Codeception Yii2 Client
Last active August 29, 2015 14:13
Extension of Codeception\Lib\Connector\Yii2, used by CodeceptionYii2Module gist, for Multiple DBs and Shared Transactions.
<?php
namespace tests\codeception\common\Lib\Connector;
use Yii;
/**
* Extended Codeception Yii2 Client:
*
* This custom class extends the original Codeception\Lib\Connector\Yii2 to
@jkovacs618
jkovacs618 / Extended Codeception Yii2 Module
Last active August 29, 2015 14:13
Extension of Codeception\Module\Yii2 to support multiple DB Connections and Shared Transactions.
<?php
namespace tests\codeception\common\Module;
use Codeception\Lib\Interfaces\ActiveRecord;
/**
* Extended Codeception Yii2 Module:
*
* This module provides integration with [Yii framework](http://www.yiiframework.com/) (2.0).
* This custom module extends the original Codeception\Module\Yii2 class to support Multiple DBs and Shared Transactions.
@jkovacs618
jkovacs618 / AppActiveRecord-populateRecord.php
Last active August 29, 2015 14:05
Yii2 custom AppActiveRecord class used to extend yii\db\ActiveRecord to override populateRecord to improve performance of large find() queries.
<?php
namespace common\models\db;
/**
* AppActiveRecord: Extension of ActiveRecord class to override the static populateRecord function for performance.
*/
class AppActiveRecord extends \yii\db\ActiveRecord
{
/**
* Override private BaseActiveRecord->_attributes for use by overridden populateRecord function below.
@jkovacs618
jkovacs618 / AppActiveRecord.php
Created August 26, 2014 16:22
Yii2 custom AppActiveRecord class used to extend yii\db\ActiveRecord to provide a static find($config) function for backwards-compatibility with Yii 1.1 CActiveRecord->find*(array) functions.
<?php
namespace common\models\db;
class AppActiveRecord extends \yii\db\ActiveRecord
{
/**
* Override the \yii\db\ActiveRecord::find() static function to allow passing in an array of configuration properties.
* Also, return a custom AppActiveQuery object that overrides functionality of ActiveQuery and allows Caching.
*
* @param Array|null $config The array of key value pairs to set the ActiveQuery properties on construction.
@jkovacs618
jkovacs618 / AppActiveQuery.php
Created August 26, 2014 16:17
Yii2 custom AppActiveQuery class used to extend yii\db\ActiveQuery to provide a cache function for backwards-compatibility with Yii 1.1 CActiveRecord->cache.
<?php
namespace common\models\db;
class AppActiveQuery extends \yii\db\ActiveQuery
{
private $cacheDuration = null;
private $functionName = '';
private $q = null;
/**