Last active
December 12, 2015 06:09
-
-
Save novalagung/4727109 to your computer and use it in GitHub Desktop.
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 | |
defined('SYSPATH') or die('No direct script access.'); | |
class Model_Child extends Model_Parent { | |
} |
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 | |
defined('SYSPATH') or die('No direct script access.'); | |
class Model_Parent extends ORM { | |
public function __construct() { | |
parent::__construct(); | |
} | |
public function next_id($model = '') { | |
if ($model == '') { | |
$model = new ReflectionClass(get_class($this)); | |
$model = str_replace('Model_', '', $model->name); | |
} | |
$o = ORM::factory($model)->limit(0)->offset(0)->order_by($this->_primary_key, 'desc')->find(); | |
return $o->get($this->_primary_key) + 1; | |
} | |
} |
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
<?= ORM::factory('child')->next_id() ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment