在这篇文章中,我们将带领您了解JOINed表中的条件显示错误CakePHP的全貌,同时,我们还将为您介绍有关Cakephp$this->paginate具有自定义JOIN和过滤选项、cakephp/a
在这篇文章中,我们将带领您了解JOINed表中的条件显示错误CakePHP的全貌,同时,我们还将为您介绍有关Cakephp $this-> paginate具有自定义JOIN和过滤选项、cakephp / app / webroot /在Apache sereper上安装cakephp时未find、CakePHP 1.3错误:致命错误:在第248行的/var/www/html/projectname/cake/libs/cache/file.php中的非对象上调用成员函数cd()、cakephp 2.1中没有找到类’CakeLog’错误的知识,以帮助您更好地理解这个主题。
本文目录一览:- JOINed表中的条件显示错误CakePHP
- Cakephp $this-> paginate具有自定义JOIN和过滤选项
- cakephp / app / webroot /在Apache sereper上安装cakephp时未find
- CakePHP 1.3错误:致命错误:在第248行的/var/www/html/projectname/cake/libs/cache/file.php中的非对象上调用成员函数cd()
- cakephp 2.1中没有找到类’CakeLog’错误
JOINed表中的条件显示错误CakePHP
我有两个表employee_personals
,用于存储该员工的所有个人记录,并telephone_bills
存储每个月支付给特定员工的电话费。现在employeePersonalsController.php
我有一个名为的函数api_show_employees()
,类似于以下内容:
function api_show_employees() { //$this->autoRender = false; //Configure::write("debug",0); $office_id = ''''; $cond = ''''; if(isset($_GET[''office_id'']) && trim($_GET[''office_id'']) != '''') { $office_id = $_GET[''office_id'']; $cond[''EmployeePersonal.office_id''] = $office_id; } if(isset($_GET[''telephoneBillTo'']) && isset($_GET[''telephoneBillFrom'']) ) { if($_GET[''telephoneBillTo''] != '''' && $_GET[''telephoneBillFrom''] != '''') { $cond[''TelephoneBill.bill_from''] = $_GET[''telephoneBillFrom'']; $cond[''TelephoneBill.bill_to''] = $_GET[''telephoneBillTo'']; } } $order = ''EmployeePersonal.name''; // $employee = $this->EmployeePersonal->find(''all''); $employee = $this->EmployeePersonal->find(''all'',array(''order'' => $order,''conditions''=>$cond)); //return json_encode($employee); }
此功能基本上可以找到在给定期间内支付账单的所有员工。但是我遇到一个错误
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column ''TelephoneBill.bill_from'' in ''where clause''
型号EmployeePersonal.php
::
var $hasMany = array( ''TelephoneBill'' => array( ''className'' => ''TelephoneBill'', ));
TelephoneBill.php
public $name = ''TelephoneBill'';var $hasMany = array(''EmployeePersonal'');
注意:如果我跳过bill_from
和bill_to
条件,我将得到TelephoneBill
array的结果!
答案1
小编典典详细信息/注释:
1)看起来您正在使用recursive
。不要那样做改用Containable
2)您不能根据条件限制父模型包含的数据/包含递归的表中的数据- **而是使用Joins
2b)或者,您可以从另一个方向查询,并查询TelephoneBill
条件,然后包含EmployeePersonal
。
Cakephp $this-> paginate具有自定义JOIN和过滤选项
这是我通过$this-> passedArgs处理搜索选项的代码的一部分
function crediti() { if(isset($this->passedArgs['Search.cognome'])) { debug($this->passedArgs); $this->paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*','%',$this->passedArgs['Search.cognome']); } if(isset($this->passedArgs['Search.nome'])) { $this->paginate['conditions'][]['Member.nome LIKE'] = str_replace('*',$this->passedArgs['Search.nome']); }
之后
$this->paginate = array( 'joins' => array(array('table'=> 'reservations','type' => 'INNER','alias' => 'Reservation','conditions' => array('Reservation.member_id = Member.id','Member.totcrediti > 0' ))),'limit' => 10); $this->Member->recursive = -1; $this->paginate['conditions'][]['Reservation.pagamento_verificato'] = 'SI'; $this->paginate['fields'] = array('disTINCT Member.id','Member.nome','Member.cognome','Member.totcrediti'); $members = $this->paginate('Member'); $this->set(compact('members'));
INNER JOIN工作很好,但$this->分页忽略每个$this-> paginate [‘conditions’] [] by $this-> passedArgs,我无法理解我如何处理它.
在调试中没有查询,只是原来的INNER JOIN.
有人可以帮我吗?
非常感谢你
更新:
没有运气
我已经处理了这部分代码了好几个小时.
如果我使用
if(isset($this->passedArgs['Search.cognome'])) { $this->paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*',$this->passedArgs['Search.cognome']); } $this->paginate['conditions'][]['Member.sospeso'] = 'SI'; $this->Member->recursive = 0; $this->paginate['fields'] = array( 'Member.id','Member.codice_fiscale','Member.sesso','Member.region_id','Member.district_id','Member.city_id','Member.date','Member.sospeso','Region.name','district.name','City.name'); $sospesi = $this->paginate('Member');
一切顺利,从调试我收到第一个条件和条件从$this-> paginate [‘条件] [] [‘Member.cognome LIKE’],你可以看到
array $this-> passedArgs
Array ( [Search.cognome] => aiello ) Array $this->paginate['conditions'][] ( [0] => Array ( [Member.cognome LIKE] => aiello ) [1] => Array ( [Member.sospeso] => NO )
但是,如果我使用分页写入联接,那么$this-> paginate [‘conditions’] []将忽略所有的东西,并让我从调试开始,只需$this-> paginate [‘conditions’] [] [ ‘Reservation.pagamento_verificato’] =’SI’;
另一点信息.
如果我把所有处理$this-> paginate [‘conditions’] [] [‘Reservation.pagamento_verificato’] =’SI’的东西;
在$this-> paginate JOIN之前,在$this-> paginate [‘conditions’] []中不会有任何内容.
// Limit widgets shown to only those owned by the user. $this->paginate = array( 'conditions' => array('User.id' => $this->Auth->user('id')),'joins' => array( array( 'alias' => 'User','table' => 'users','conditions' => '`User`.`id` = `Widget`.`user_id`' ) ),'limit' => 20,'order' => array( 'created' => 'desc' ) ); $this->set( 'widgets',$this->paginate( $this->Widget ) );
这使得查询类似于:
SELECT widgets.* FROM widgets INNER JOIN users ON widgets.user_id = users.id WHERE users.id = {current user id}
还有分页.
cakephp / app / webroot /在Apache sereper上安装cakephp时未find
我在做什么:
我已经用cakePHP 2.2.1开发了一个web应用程序。 现在我想将它安装在Apache服务器(版本2.2.16)上。
错误 :
在此服务器上找不到所请求的URL / inetpub / wwwroot / cakePHP / app / webroot。
XAMPP图像不显示/损坏( – 可能.htaccess)
防止执行父文件夹的.htaccess
.htaccess 301redirect不工作?
.htaccess将下划线重写为超链接,剥离扩展和删除尾部下划线
htaccess外部重写/内部redirect
我做了什么:
这在我看来是一个.htaccess错误。
我查了一下
LoadModule rewrite_module libexec / apache2 / mod_rewrite.so
没有注释。
我确信
选项FollowSymLinks AllowOverride全部
启用了wwwroot / cakePHP目录。 然后我检查了所有的.htaccess文件都符合文档 。
仍然没有运气。
题:
有谁知道发生了什么事?
编辑:这里是app / webroot / index.PHP:
<?PHP /** * Index * * The Front Controller for handling every request * * PHP 5 * * CakePHP(tm) : Rapid Development Framework (http://cakePHP.org) * copyright 2005-2012,Cake Software Foundation,Inc. (http://cakefoundation.org) * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @copyright copyright 2005-2012,Inc. (http://cakefoundation.org) * @link http://cakePHP.org CakePHP(tm) Project * @package app.webroot * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.PHP) */ /** * Use the DS to separate the directories in other defines */ if (!defined(''DS'')) { define(''DS'',DIRECTORY_SEParaTOR); } /** * These defines should only be edited if you have cake installed in * a directory layout other than the way it is distributed. * When using custom settings be sure to use the DS and do not add a trailing DS. */ /** * The full path to the directory which holds "app",WITHOUT a trailing DS. * */ if (!defined(''ROOT'')) { define(''ROOT'',dirname(dirname(dirname(__FILE__)))); } /** * The actual directory name for the "app". * */ if (!defined(''APP_DIR'')) { define(''APP_DIR'',basename(dirname(dirname(__FILE__)))); } /** * The absolute path to the "cake" directory,WITHOUT a trailing DS. * * Un-comment this line to specify a fixed path to CakePHP. * This should point at the directory containing `Cake`. * * For ease of development CakePHP uses PHP''s include_path. If you * cannot modify your include_path set this value. * * Leaving this constant undefined will result in it being defined in Cake/bootstrap.PHP */ //define(''CAKE_CORE_INCLUDE_PATH'',ROOT . DS . ''lib''); /** * Editing below this line should NOT be necessary. * Change at your own risk. * */ if (!defined(''WEbroOT_DIR'')) { define(''WEbroOT_DIR'',basename(dirname(__FILE__))); } if (!defined(''WWW_ROOT'')) { define(''WWW_ROOT'',dirname(__FILE__) . DS); } if (!defined(''CAKE_CORE_INCLUDE_PATH'')) { if (function_exists(''ini_set'')) { ini_set(''include_path'',ROOT . DS . ''lib'' . PATH_SEParaTOR . ini_get(''include_path'')); } if (!include (''Cake'' . DS . ''bootstrap.PHP'')) { $Failed = true; } } else { if (!include (CAKE_CORE_INCLUDE_PATH . DS . ''Cake'' . DS . ''bootstrap.PHP'')) { $Failed = true; } } if (!empty($Failed)) { trigger_error("CakePHP core Could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.PHP. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.",E_USER_ERROR); } App::uses(''dispatcher'',''Routing''); $dispatcher = new dispatcher(); $dispatcher->dispatch(new CakeRequest(),new CakeResponse(array(''charset'' => Configure::read(''App.encoding''))));
url百分比编码不起作用
使用htaccess以https支持添加www
将http和https请求redirect到新主机
用于漂亮URL的Apache Mod重写不起作用
如何编辑.htpasswd使用PHP?
问题解决了:
首先,如果你的网站是
http://www.example.info/tmp/
分别放在三个.htaccess中:
RewriteBase /tmp/ RewriteBase /tmp/app/ RewriteBase /tmp/app/webroot
并更换
RewriteRule ^(.*)$ index.PHP [QSA,L]
通过
RewriteRule ^(.*)$ index.PHP?url=$1 [QSA,L]
总结
以上是小编为你收集整理的cakephp / app / webroot /在Apache sereper上安装cakephp时未find全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
CakePHP 1.3错误:致命错误:在第248行的/var/www/html/projectname/cake/libs/cache/file.php中的非对象上调用成员函数cd()
服务器配置:
CakePHP 1.3.x版本
PHP版本5.3.6
致命错误:在第248行的/var/www/html/xyz/cake/libs/cache/file.PHP中的非对象上调用成员函数cd()
我试图在Google上搜索,但没什么用处.
任何想法,如何解决这个问题?
问候 !
解决方法
cakephp 2.1中没有找到类’CakeLog’错误
我在Windows Server 2008中安装了cakePHP 2.1,它给了我以下错误
Fatal error: Class “CakeLog” not found in
“C:\wamp\www\foldername\app\Config\bootstrap.PHP” on line 172Fatal error: Class “CakeLog” not found in
“C:\wamp\www\foldername\lib\Cake\Error\ErrorHandler.PHP” on line 200
而当我在Windows 7 32位服务器上运行它时,它运行顺利.
任何人都可以告诉我如何让它在Windows Server 2008上运行.
解决方法:
我已经多次遇到这个问题了,我的解决方案一直都是
>如果从先前的应用程序复制此安装,请删除文件&& tmp目录中的文件夹并重新创建它们以及所有子文件夹,例如缓存(模型,持久性,视图)和日志
>确保/ tmp目录是“可写”chmod -R 777
p.s给出的错误信息不够具有描述性
今天的关于JOINed表中的条件显示错误CakePHP的分享已经结束,谢谢您的关注,如果想了解更多关于Cakephp $this-> paginate具有自定义JOIN和过滤选项、cakephp / app / webroot /在Apache sereper上安装cakephp时未find、CakePHP 1.3错误:致命错误:在第248行的/var/www/html/projectname/cake/libs/cache/file.php中的非对象上调用成员函数cd()、cakephp 2.1中没有找到类’CakeLog’错误的相关知识,请在本站进行查询。
本文标签: