Example #1
0
 public function delete()
 {
     if (self::REALLY_DELETE) {
         if ($this - profile !== null) {
             $this->profile->delete();
         }
         return parent::delete();
     } else {
         $this->status = self::STATUS_REMOVED;
         return $this->save(false, array('status'));
     }
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  *
  * @param string $className
  *        	active record class name.
  * @return RecoveryRequest the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Example #3
0
     * Default sort column
     */
    static function _db_sort_column()
    {
        return 'age';
    }
    /**
     * Simple database layout
     */
    static function _db_columns()
    {
        return array('id' => 'integer', 'name' => 'string', 'age' => 'integer', 'is_happy' => 'boolean');
    }
}
/* Register the Person/Person_ class as an AutoRecord */
AutoRecord::register('Person');
/* Database connection (in-memory SQLite database) */
$db = DB::get_instance('sqlite', array('filename' => ':memory:', 'debug' => true, 'debug_print' => true));
/* Create the schema (sqlite ignores column types, though) */
$db->prepare_execute('CREATE TABLE Person (
	id INTEGER PRIMARY KEY,
	name VARCHAR(255),
	age INTEGER,
	is_happy BOOLEAN
	)');
$pq = $db->prepare('INSERT INTO Person (id, name, age, is_happy) VALUES (?int?, ?str?, ?int?, ?bool?)');
$pq->execute(1, 'A', 10, true);
$pq->execute(2, 'B', 11, false);
$pq->execute(3, 'C', 12, false);
$pq->execute(4, 'D', 13, null);
$pq->execute(5, 'E', 14, false);