本文整理汇总了PHP中Options::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::find方法的具体用法?PHP Options::find怎么用?PHP Options::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disableOption
public function disableOption($option_id)
{
$option = Options::find($option_id);
$option->active = 0;
$option->save();
return Redirect::back();
}
示例2: showAction
public function showAction($question_id)
{
$this->view->poll = Questions::findFirst($question_id);
//$this->view->options = Options::findByQuestionId($question_id);
$this->view->options = Options::find(array('question_id = ?0', 'bind' => array($question_id), 'order' => 'vote DESC'));
}
示例3: rows
<?php
/**
* Models Plugin Example
* Add this to a view in your template
*/
// Require the model file
require MODELS_PATH . 'Options.php';
// Find Example with cache (returns array of objects)
$all_opts = Options::find()->cache('cacheIdentifier')->all();
// Find Example with select
$three_opts = Options::find()->limit(3)->select(['option_id', 'option_name'])->orderBy('option_id DESC')->all();
// FindByPk Example (returns Object)
$opt1 = Options::findByPk(1);
// Print out the record with Pk = 1
echo '<h2>Row found by Primary Key</h2>';
echo "Primary Key 1: " . $opt1->option_name . " => " . $opt1->option_value . "<br>";
// Print out the three first rows in Options
echo '<h2>Three last rows with select</h2>';
foreach ($three_opts as $opt) {
echo $opt->option_name . '<br>';
}
// Print all rows in Options (cached)
echo '<h2>All rows (Cached)</h2>';
foreach ($all_opts as $opt) {
echo $opt->option_name . '<br>';
}