我是cakephp的初学者,我想IN在find方法中使用SQL 运算符,我有单词表.
我的代码是:
$this->Word->find('Word.wordid in (83,82)');
Run Code Online (Sandbox Code Playgroud)
,此代码创建此查询:
SELECT `Userword`.`userwordid`, `Userword`.`userid`, `Userword`.`wordid`,
`Userword`.`date`, `Userword`.`levelid` FROM `userwords` AS `Userword` WHERE
`Userword`.`wordid` = (82)
Run Code Online (Sandbox Code Playgroud)
但我需要这个查询
SELECT `Userword`.`userwordid`, `Userword`.`userid`, `Userword`.`wordid`,
Userword`.`date`, `Userword`.`levelid` FROM `userwords` AS `Userword` WHERE
`Userword`.`wordid` IN (83,82)
Run Code Online (Sandbox Code Playgroud)
怎么能得到这样的查询(使用IN运算符)
谢谢.
我想在我的项目中使用模块化扩展HMVC,如下所示:
modules
module01
models
models01.php
controllers
controller01.php
views
views01.php
module02
models
models01.php
controllers
controller01.php
views
views01.php
‘
‘
Run Code Online (Sandbox Code Playgroud)
我想使用'models01.php' module01,有什么办法吗?
我使用php作为我的web项目,但我需要单独的CSS这个着色补充.
因此,我需要在Firefox和Internet Explorer中运行的代码.
此代码已编写,但在Internet Explorer中不起作用:
.tbl_css col:nth-child(odd){
}
.tbl_css col:nth-child(even){
}
Run Code Online (Sandbox Code Playgroud) 什么是自动完成助手的最佳IDE.因为我不记得html助手或其他的所有方法或属性,例如:
$this->Html->tableHeaders(array('Date','Title','Active'));
Run Code Online (Sandbox Code Playgroud)
但我应该写tableHeaders和IDE不能识别Html的属性和方法.
谢谢.
我正在使用moodle并且我更改了我的网站的位置,但我遇到了这个错误.
我的config.php是:
<?php /// Moodle Configuration File
unset($CFG);
$CFG->dbtype = 'mysql';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'lightsys_test';
$CFG->dbuser = 'lightsys_test';
$CFG->dbpass = '123456a';
$CFG->dbpersist = false;
$CFG->prefix = 'mdl_';
$CFG->wwwroot = 'http://www.lightsystem.ir/aya/moodle';
$CFG->dirroot = '/home/lightsys/public_html/aya/moodle';
$CFG->dataroot = '/home/lightsys/public_html/aya/moodledata';
$CFG->admin = 'admin';
$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode
require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS …Run Code Online (Sandbox Code Playgroud) 我正在使用cakephp并使用acl.但我面对这个错误.
DbAcl::check() - Failed ARO/ACO node lookup in permissions check.
Run Code Online (Sandbox Code Playgroud)
感谢帮助.
可能重复:
在PHP中将字符串编码为带有BOM的UTF-8
我可以使用此代码从php导出csv文件
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
$output = fopen('php://output', 'w');
Run Code Online (Sandbox Code Playgroud)
但是这段代码用charset创建文件,utf-8 without BOM但我需要charset utf-8.
是这个问题的方法?
怎么用表与自己联系?我用cakephp和table是Section:
create table SECTIONS
(
SECTIONID int(11) not null auto_increment,
TITLE char not null,
CONTROLID int(11) not null,
SECTIONPARENTID int(11),
primary key (SECTIONID)
)
Run Code Online (Sandbox Code Playgroud)
这个表与自己有关联,我使用属于并且有很多关联,我的模型是:
class Section extends AppModel {
var $name = 'Section';
var $primaryKey = 'SECTIONID';
var $displayField = 'TITLE';
}
Run Code Online (Sandbox Code Playgroud)
我使用属于并且在两个表中有许多关联.但我不能在这个例子中使用.感谢帮助.
我正在使用cakephp并创建此条件:
$conditions = array("Userword.levelid"=>0, "Userword.userid"=>$this->Auth->user('UserId'),"date(Userword.date)"=>"DATE_SUB(CURDATE(),INTERVAL 0 DAY)");
$Userword = $this->paginate(null, $conditions);
Run Code Online (Sandbox Code Playgroud)
使用此选择的蛋糕:
`Userword`.`userwordid`, `Userword`.`userid`, `Userword`.`wordid`, `Userword`.`date`, `Userword`.`levelid`, `Word`.`wordid`, `Word`.`word`, `Word`.`meaning`, `User`.`UserId`, `User`.`Email`, `User`.`password`, `User`.`username`, `User`.`cell`, `User`.`web` FROM `userwords` AS `Userword` LEFT JOIN `words` AS `Word` ON (`Userword`.`wordid` = `Word`.`wordid`) LEFT JOIN `users` AS `User` ON (`Userword`.`userid` = `User`.`UserId`) WHERE date(`Userword`.`date`) = 'DATE_SUB(CURDATE(),INTERVAL 2 DAY)'
Run Code Online (Sandbox Code Playgroud)
但是由此选择mysql无法返回记录,因为此选择中的cakephp '在最后一段中使用此字符().当我删除此字符并在phpmyadmin此代码中测试此代码返回行.下面的两张图片显示了这一点:


我是PHP程序员,但我不知道这个运算符的名称
- >这个运算符在php中使用OOP.
例如
$this->get();
Run Code Online (Sandbox Code Playgroud) 我使用CakePHP 1.3,我想更改此消息:
您无权访问该位置.
到(例如):
哦对不起
该代码中显示消息:
echo $ this-> Session-> flash('auth');
我将app_controller更改为
class AppController extends Controller {
var $components = array('Auth', 'Session', 'Acl');
function beforeFilter() {
$this->Auth->authorize = 'actions';
$this->Auth->autoRedirect = false;
if ($this->params['controller'] == 'pages') {
$this->Auth->allow('*');
}
$this->Auth->allow('pages');
$this->Auth->loginError = "This message shows up when the wrong credentials are used";
$this->Auth->authError = "This error shows up with the user tries to access a part of the website that is protected.";
}
Run Code Online (Sandbox Code Playgroud)
}
但我面对同样的信息.
我想从表(mysql)中的一个记录的两个字段给出max.
我的表是:
CREATE TABLE `testtbl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`startdate` date NOT NULL,
`enddate` date NOT NULL,
PRIMARY KEY (`userid`)
)
Run Code Online (Sandbox Code Playgroud)
例如我的数据是:
1,'2012-12-04','2013-02-02'
但是当我使用下面的sql时,我面临着错误.
sql代码是:
select max(startdate,enddate) from `testtbl`
Run Code Online (Sandbox Code Playgroud) 我知道会话固定是在PHP中破解网站的方法.
会话修复是一种攻击,允许攻击者劫持有效的用户会话
会话固定,
但我不知道这可以防止我的项目中出现此问题.
是描述解决方案的方式或样本.
cakephp ×6
php ×4
mysql ×2
acl ×1
associations ×1
autocomplete ×1
cakephp-1.3 ×1
codeigniter ×1
css ×1
csv ×1
database ×1
find ×1
helper ×1
ide ×1
in-operator ×1
max ×1
model ×1
moodle ×1
oop ×1
operators ×1
orm ×1
utf-8 ×1