Skip to content

Instantly share code, notes, and snippets.

View cottonaf's full-sized avatar

Andrew Cotton cottonaf

  • Brax
  • San Diego, CA
View GitHub Profile
<?php
/**
* Flavor 1:
* By the time this was completed I realized I had created a monster.
* In interests of showing I'm capable of over-engineering things, however,
* I have included it.
*/
for( $i = 1; $i <= 100; $i++ )
{
$ret = [];
<?php
class ActiveRecord extends CActiveRecord
{
/**
* Check if the current record already exists in the database.
*
* $exludeColumns array of attribute names; these columns/attribute names will be excluded from search.
* @return boolean
*
@cottonaf
cottonaf / ActiveRecord.php
Last active August 29, 2015 14:21
Multi-insert yii models
<?php
class ActiveRecord extends CActiveRecord
{
/**
* Requires >= Yii 1.1.14;
*
* @recordAttributes is an array of key=>value pairs which can be inserted into @tableName
* @tableName is the table into which these values will be inserted. Will attempt to determine the name itself
* if left to its own devices.
@cottonaf
cottonaf / ActiveRecord.php
Last active August 29, 2015 14:21
Soft delete, or logical delete addition for yii 1.x
<?php
class ActiveRecord extends CActiveRecord
{
/**
* Based on ActiveRecord delete() but instead of actually deleting it sets an attribute to deleted=true.
* Others have chosen to implement this as a behavior; this should be standard AR practice, but in order
* to maintain backwards compatibility with a few models which use delete() to actually delete models it must not be overridden (delete).
*
* Performs a logical delete.