База
Код: Выделить всё
CREATE TABLE `ips` (
`id` int(11) NOT NULL,
`ip` int(10) UNSIGNED NOT NULL,
`mac` varchar(17) DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Код: Выделить всё
public function beforeSave($insert) {
$this->ip = new \yii\db\Expression('INET_ATON(:ip)', ['ip' => $this->ip]);
return parent::beforeSave($insert);
}
public static function find() {
return parent::find()->select(['INET_NTOA(`ip`) `ip`']);
}
Код: Выделить всё
public function actionIndex() {
$model = Ips::find()->where(['id' => 89])->one();
echo $model->ip . "<br/>";
return $this->render('index');
}