cakephp-1.3

CakePHP Pagination count not matching query?

心不动则不痛 提交于 2019-12-05 01:34:40
问题 I've got a fairly modified pagination query using a number of Joins etc - but for some reason the paginator->counter() never matches the results from the count query. You can see it in action at http://dev.qreer.com/ - by choosing various options on the LHS navigation, the query output is below and the paginator count appears to be pretty random. Any idea where I can start looking to debug this? In the Jobs Controller: $this->paginate = $this->Job->paginateParams($data); $jobs = $this-

CakePHP find with MAX

旧城冷巷雨未停 提交于 2019-12-05 01:08:33
Tables and dummy data: CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) unsigned NOT NULL auto_increment, `user_id` int(11) unsigned NOT NULL, `node_id` int(11) unsigned NOT NULL, `reciever_id` int(11) unsigned NOT NULL, `created` datetime default NULL, `modified` datetime default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; INSERT INTO `messages` (`id`, `user_id`, `node_id`, `reciever_id`, `created`, `modified`) VALUES (1, 1, 1, 15, '2011-12-07 00:00:00', '2011-12-07 02:00:00'), (2, 15, 1, 1, '2011-12-07 02:00:00', '2011-12-07 02:00:00'), (3, 15, 2, 1,

CakePHP multiple select “selected” is not working

痞子三分冷 提交于 2019-12-05 00:08:01
I have a multiple select input in my edit form:- <?php echo $this->Form->input('Article.tags', array('type' => 'select', 'multiple' => true, 'options' => $tags, 'selected' => array($selected))); ?> When echo-ed, the $selected variable will look like this:- "MySQL", "PHP" However, the input does not automatically select the option that matches the tag. However, when I manually put in the selected option, it will automatically select that two option; e.g. <?php echo $this->Form->input('Article.tags', array('type' => 'select', 'multiple' => true, 'options' => $tags, 'selected' => array("MySQL",

How to include javascript in cakephp 1.3?

会有一股神秘感。 提交于 2019-12-04 20:55:36
Wait moment this question not duplicated..it is sample and difficult at the same time. This simple problem make me crazy.. http://www.mediafire.com/?2vi2kc7tpqiw1to This is slide code contain CSS, HTML, jQuery code. This slide works fine, but when I include this slide in cakephp it is not working. I put jQuery files and CSS in webroot and put the code to include in layout/default.ctp like this echo $javascript->link('jcookie.js'); echo $javascript->link('jquery-1.3.2.min.js'); echo $javascript->link('jcarousellite.js'); echo $javascript->link('jquery-1.js'); but still nothing happen ..please

CakePHP with Lucene

。_饼干妹妹 提交于 2019-12-04 17:01:45
I am trying to implement Lucene with cakephp and following this guide http://jamienay.com/2010/01/zend_search_lucene-datasource-for-cakephp/ Am getting this error ConnectionManager::loadDataSource - Unable to import DataSource class .ZendSearchLuceneSource i have placed the Vendor files in app/vendors/Zend/ Added this in the bootstrap.php ini_set('include_path', ini_get('include_path') . ':' . CAKE_CORE_INCLUDE_PATH . DS . '/vendors'); /** * AutoLoading Zend Vendor Files */ function __autoload($path) { if(substr($path, 0, 5) == 'Zend_') { include str_replace('_', '/', $path) . '.php'; } return

how to create dynamic navigation menu cakephp

。_饼干妹妹 提交于 2019-12-04 16:35:21
How can I build navigation menu from categories and sub categories, like this: http://mysite/categories/view/1/2 I tried menu builder 1.01 but it only works for acl users. I also read this tutorial , but it was not helpful. Your first link doesn't work. Frankly, I'm not even sure I understand what you're trying to do. The second link you supplied - I admit I only looked at the first code snippet - doesn't use a database table. If you want your menu to be dynamic, as in based off controller actions, that makes sense. If you want it to be "dynamic" as in having dynamic control over menu items

can CakePHP automatically create tables from models?

ε祈祈猫儿з 提交于 2019-12-04 13:05:19
In python::Pylons i'm able to issue a setup-app command and it will look at my Models and issue the appropriate CREATE TABLE or CREATE INDEX ddl for my particular database. it seems like this would be a feature in CakePHP, but i'm having trouble finding it. in fact i see this in the manual: "You can create your database tables as you normally would. When you create your Model classes, they'll automatically map to the tables that you've created." which leads me to believe it doesn't exist? No, it's other way around - you can create models, controllers and views by having DB schema. It's more

Assigning Layout in cakephp

ⅰ亾dé卋堺 提交于 2019-12-04 13:04:38
Can we define a Layout for whole controller in that particular controller?I have used before filter of the appcontroller for this purpose earlier but it doesnt solves it any more.So i need that there should be some definition of layout in controller that would apply for all the actions of that controller. Regards use it: inside your action $this->layout = 'mylayout'; you have to create that layout in view/layout/mylayout.ctp or add this function to controller to set layout for each action of controller function beforeFilter() { parent::beforeFilter(); $this->layout = 'mylayout'; } The best way

CakePHP: How do I count the number of hasMany records in a find?

為{幸葍}努か 提交于 2019-12-04 11:15:18
I have two models, Post hasMany Comment . How do I select all Post that have less than two Comment ? I tried using a find with 'fields'=>array('COUNT(Comment.id) as numComments','Post.*') , (and then doing a numComments < 2 in 'conditions' ). But, I get a Unknown column 'Comment.id' in 'field list' error. Thanks! EDIT: I've gotten CakePHP to generate this query: SELECT `Post`.*, FROM `posts` AS `Post` LEFT JOIN comments AS `Comment` ON (`Post`.`id` = `Comment`.`text_request_id`) WHERE COUNT(`Comment`.`id`) < 2 GROUP BY `Comment`.`post_id` LIMIT 10 But I get an error #1111 - Invalid use of

How to make temporary link for a downloadable file

大憨熊 提交于 2019-12-04 11:11:46
问题 I am making a project for a temporary download link for me to protect the file from hotlinkers... I believe that this is possible to do so.. because we all know that many of file sharing site " don't wanna mention any "... their link for the file has expiration... Ex. If I download one file from their site they give a direct link to click it right? but then that link will expire right after a few hours or minutes. How should I know that the link was expired? If I copy the same link on my