我一直在使用Yii一段时间,当我想从数据库中提取数据时,我通常只使用findByAttributes.
$model=Auction::model()->findAllByAttributes(array('status'=>'1'));
Run Code Online (Sandbox Code Playgroud)
或类似的规定.
我的问题是,我将如何处理大于类型的情况?我试过了
$model=Auction::model()->findAllByAttributes(array('starttime'>=$date));
Run Code Online (Sandbox Code Playgroud)
其中日期已分配当前日期/时间设置,但这会导致错误.所以我的问题是我需要使用条件和/或参数吗?我应该在模型中使用Criteria或CActiveDataProvider这样的东西吗?
我希望有人指出我正确的方向.我总是通过使用findAll()来获得,但我知道他们是更好的方法.关于什么以及何时使用属性,条件,参数等的一般信息也很好.
我已阅读Yii文档并搜索了大量网站以获取这些问题的答案,我找不到它.
我正在尝试使用我创建的自定义类来发送邮件,以便我可以保持控制器文件很薄.我创建了自定义类并将其放在components文件夹中.然后我补充说:
'sendMail' => array(
'class'=>'application.components.SendMail.',
),
Run Code Online (Sandbox Code Playgroud)
在我的主配置文件中的主要组件下面.
这应该允许我直接访问类正确吗?我尝试使用:
Yii::app()->SendMail->MailerConfirmation();
Run Code Online (Sandbox Code Playgroud)
和:
Yii:app()->MailerConfirmation();
Run Code Online (Sandbox Code Playgroud)
而我最终得到的只是错误.
谁能告诉我如何包含自定义组件?也许我这样做错了?
我在Yii中使用单选按钮,无论我做什么,我都无法获得所选按钮的值.我确信这只是一件简单的事情.我不使用radioButtonList,因为我希望每个按钮都存在于自己的div中,上面有一个图像.
这是我的视图中的代码......
<?php $this->pageTitle=Yii::app()->name; ?>
<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'lead_form',
'enableAjaxValidation'=>false,
)); ?>
<h3>Choose Your Prize!</h3>
<div id="prizes">
<div class="prize">
<h3>Paypal</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>1)); ?>
</div>
<div class="prize">
<h3>Check</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>2)); ?>
</div>
<div class="prize">
<h3>AlertPay</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>3)); ?>
</div>
<div class="prize">
<h3>Iphone 4</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>4)); ?>
</div>
<div class="prize">
<h3>Ipad 2</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>5)); ?>
</div>
<div class="prize">
<h3>Custom</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>6)); ?>
</div>
</div>
<h3>Enter Your Email</h3>
<div …Run Code Online (Sandbox Code Playgroud) 这是我所拥有的网站表单的底部.在添加TOS协议复选框之前,一切正常.现在,无论是否选中该框,它都会提醒用户必须选中该框.任何帮助将不胜感激.
<input type='checkbox' value='yes' name='tosagree' id='tosagree'> <p>I have read and agree to the privacy policy and terms of use found on this site.</p>
<input type='submit' id='submit' name='submit' value='submit'><br /><br />
</form>
</div>
<script type='text/javascript'>
function validateForm()
{
var asking=document.forms["form"]["asaskingprice"].value,
reasons=document.forms["form"]["asreasons"].value,
timelines=document.forms["form"]["astimelines"].value,
sources=document.forms["form"]["assources"].value,
tos=document.forms["form"]["tosagree"].value;
if (asking==null || asking=="")
{
alert("Asking price must be filled out");
return false;
}
if (reasons==null || reasons=="")
{
alert("reasons must be filled out");
return false;
}
if (timelines==null || timelines=="")
{
alert("timelines must be filled out"); …Run Code Online (Sandbox Code Playgroud)