select() ->where('session_id=?', session_id()); $row = $this->fetchRow($select); if ($row) { return $row; } $select = $select->where('IP=?', $ip); return $this->fetchRow($select); } public function create() { $ip = @$_SERVER['REMOTE_ADDR']; $attempt = $this->createRow(); $attempt->IP = $ip; $attempt->session_id = session_id(); $attempt->failed_attempts = 1; $attempt->last_attempt = date('Y-m-d H:i:s'); $attempt->save(); } }