Created
April 22, 2015 09:00
-
-
Save cebe/c66e989dd8f1b55295c1 to your computer and use it in GitHub Desktop.
yii getter/setter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyClass extends \yii\base\Component | |
{ | |
private $_value; | |
public function getValue() | |
{ | |
if ($this->_value === null) { | |
$this->_value = /* your sql query here */; | |
} | |
return $this->_value; | |
} | |
// setter is optional, if not present, this will be a read only property | |
public function setValue($value) | |
{ | |
$this->_value = $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment