Gc\Script\Model::fromId PHP Method

fromId() public static method

Initiliaze from id
public static fromId ( integer $scriptId ) : Model
$scriptId integer Script id
return Model
    public static function fromId($scriptId)
    {
        $scriptTable = new Model();
        $row = $scriptTable->fetchRow($scriptTable->select(array('id' => (int) $scriptId)));
        $scriptTable->events()->trigger(__CLASS__, 'before.load', $scriptTable);
        if (!empty($row)) {
            $scriptTable = self::fromArray((array) $row);
            $scriptTable->events()->trigger(__CLASS__, 'after.load', $scriptTable);
            return $scriptTable;
        } else {
            $scriptTable->events()->trigger(__CLASS__, 'after.load.failed', $scriptTable);
            return false;
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromFakeId()
 {
     $model = $this->object->fromId(10000);
     $this->assertFalse($model);
 }
All Usage Examples Of Gc\Script\Model::fromId