我遇到了以前的开发人员编写的这段代码,我对这个find()方法的结果感到困惑。这都是胡言乱语。没有参数传递给它时它实际返回了什么?
$designation = new DesignationsModel();
$designations = $designation->find();
DesignationModel Class如下:
class DesignationsModel extends \DB\SQL\Mapper {
private $f3;
private static $instance;
protected $_name = 'designations';
// Instantiate mapper
function __construct() {
$db = \Base::instance()->get('DB');
$this->f3 = \Base::instance();
// This is where the mapper and DB structure synchronization occurs
parent::__construct($db, $this->_name);
}
$ nameations的结果在View as中使用:
<select name="designation_id" class="form-control" id="designations">
<option></option>
<?php
foreach ($designations as $designation):
if (isset($edit)):
if ($designation->id === $users->designation_id) :
?>
<option value="<?php echo $designation->id; ?>" selected><?php echo $designation->title; ?></option>
<?php
endif;
endif;
?>
<option value="<?php echo $designation->id; ?>"><?php echo $designation->title; ?></option>
<?php endforeach; ?>
</select>