cakephp,cakephp-1.3,cakephp-appmodelRelated issues-Collection of common programming errors


  • Harts
    php cakephp cakephp-1.3
    I have a cropping tool component and helper which work on cake 2.x but now I need to use this cropping tool into one of the older project in cakephp 1.3. How should I do this?The component:<?phpApp::uses(‘Component’, ‘Controller’);class JcropComponent extends Component {public $components = array(‘Session’);public $options = array(‘overwriteFile’ => true,’boxWidth’ => ‘940’);/*** Constructor*/public function __construct(ComponentCollection $collection, $options = array()) {parent::__con

  • resting
    cakephp cakephp-2.2
    Based on the information here: Using a custom renderer with Exception.renderer to handle application exceptionsI’m creating a custom error renderer that renders in XML format.Below is the sample code for the render function in app/Lib/Error/AppExceptionRenderer:public function render() {if (isset($this->controller->request->params[‘xml’])) {$this->controller->viewClass = “MyXml”;$error = array(‘app’ => array(‘error’ => ‘An unexpected error has occured.’));$this->controlle

  • user1395480
    ajax list cakephp select
    I am trying hard to refresh a list after selecting an option of a second. I have this list<select id=”ArticleShopId”> <option>Some options</option> <option>Some options 2</option> <option>Some options 3</option> </select>I have a seond<select id=”ArticleCategoryId”> <option></option> <option></option> <option></option> <option></option> </select>When I select an option of the first, ajax s

  • schizdazzle
    cakephp
    I’m a cakephp newbie – so excuse if this comes across as naive…Basically, what I am trying to do generate a random message in the validation. Currently my code is class Post extends AppModel {var $name = ‘Post’;var $validate = array(‘title’ => array(‘rule’ => ‘notEmpty’,’message’ => randomResponse()),’body’ => array(‘rule’ => ‘notEmpty’));function randomResponse() {switch($this->myRandomMessageNumber){case 1:echo ‘Are we playing charades? If so, you know I can\’t see you’;bre

  • hakre
    cakephp php parse-error
    I’m starting to make my first steps into CakePHP 1.3, and I’m having a parse error I can’t find. I’m trying the main tutorial and encountering this error:Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ‘)’ in /Applications/XAMPP/xamppfiles/htdocs/mysite.com/app/views/posts/index.ctp on line 11 the file affected is:<h1>Posts</h1> <table><tr><th>ID</th><th>Title</th><th>Creation date</th></tr><?php foreach ($posts

  • Randy Hall
    cakephp find field
    I have a database table “transactions” which has a field “account”. I want to retrieve a subset of all not-null account rows from the current set of data and have it as a virtualField I can access down the line in my view.class Transaction extends AppModel {public $virtualFields = array(“Accounts” => $this->Transaction->find(“all”, array(“conditions” => array(“not” => array(“Transaction.account” => null))))); }So that I get an array of all transactions with non-null account fie

  • user1406951
    php mysql cakephp
    I’m trying to make a link to edit a user’s info. The url for a person with id 1 would be users/edit/1echo $this->Html->link(‘Edit Info’, array( ‘controller’ => ‘users’, ‘action’ => ‘edit’,AuthComponent::user(‘id’) )); The URL shows up correctly. However, I’m trying to restrict it so only the user with that id can edit their page. So, say user 4 tries to edit user 1’s info, it will redirect. This is part of the action for edit in UsersController that should redirect. if($id !== AuthC

  • Nick
    email cakephp cakephp-2.1
    I’m building a CakePHP website that sends an e-mail like this:$email = new CakeEmail(‘default’); $email->template(‘test’); $email->emailFormat(‘html’); $email->to(array(‘[email protected]’ => ‘John Doe’)); $email->subject(‘Test E-mail’); $email->helpers(array(‘Html’, ‘Text’)); $email->viewVars(array(…) );if ($email->send()) {$this->Session->setFlash(‘The e-mail was sent!’, ‘default’, array(‘class’ => ‘alert alert-success’)); } else {$this->Session->set

  • AKKA-Web
    php cakephp
    I cant figure out what is wrong with the following code:class ArticlesController extends AppController{var $name = ‘Articles’;// Variable $today is defined here so it can be used// in other functions in this same class var $today = date(‘Y-m-d H:i:s’,strtotime(‘now’));var $helpers = array(‘Video’);function frontpageArticles(){$articles = $this->Article->find(‘all’,array(‘conditions’ => array(‘Article.published’ => 1,’Article.publish_date <=’ => $today // USED HERE))));return $a

  • deceze
    php cakephp syntax-error
    Ok, sorry for this upcoming rookie question..I was looking for a good user management plugin for cake, and i was recommended Authsome (if someone knows anything better>> plz recommend).Anyway, i’m trying to set it up using the git’s readme (very simple) but im running into a problem: t_string error. Code:Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /Applications/XAMPP/xamppfiles/htdocs/trainer/app/controllers/users_controller.php on line 7Code users_controller:<?p

  • Harts
    php cakephp cakephp-1.3
    I have a cropping tool component and helper which work on cake 2.x but now I need to use this cropping tool into one of the older project in cakephp 1.3. How should I do this?The component:<?phpApp::uses(‘Component’, ‘Controller’);class JcropComponent extends Component {public $components = array(‘Session’);public $options = array(‘overwriteFile’ => true,’boxWidth’ => ‘940’);/*** Constructor*/public function __construct(ComponentCollection $collection, $options = array()) {parent::__con

  • user1595537
    mysql cakephp find cakephp-1.3
    I’m trying to convert the output of a Model->find query into SQL to be input into a database completely separate from the current MySQL database being used by the cakePHP system. My problem is that I have several virtual fields in the models which are inevitably returned when performing a Model->find on the data. Clearly, I need to find and remove these virtual fields from the find if I am to convert the data into SQL, which will be used as input to an identical database as the original MySQL on

  • Pichan
    cakephp routing cakephp-1.3
    I’m a little at loss with CakePHP(1.3) routes when it comes to default values and persistent parameters.My current project reads the current language from the first parameter of the url (example.com/en/pagename/) and in case the language is not available, it tries to guess the language from session or cookies and if that fails, falls back to default configuration.After this, all the urls generated with Router::url() should contain the language parameter(that is, the default language if not overr

  • JD Isaacks
    php cakephp cakephp-1.3 class-variables
    I have a Product model for a multi site application.Depending on the domain(site) I want to load different data.For example instead of having a name and description fields in my database I have posh_name, cheap_name, posh_description, and cheap_description.if I set something up like this:class Product extends AppModel {var $virtualFields = array(‘name’ => ‘posh_name’,’description’ => ‘posh_description’); }Then it always works, whether accessed directly from the model or via association.Bu

  • Rob Wilkerson
    cakephp cakephp-1.3
    I’m in the process of building a plugin that includes a behavior and several related models. My goal is to make this as easy as possible for the developer using the behavior. My perfect world has the dev simply attaching the behavior to any relevant models and configuring it. The behavior interacts directly with one of the models and a hasOne association is being created on the fly, but the other models contain supporting data that is important. What I’d like to do is to have that model pull in

  • sluggerdog
    csv import cakephp-1.3 utils
    I am looking to use the cakeDC CSVimport behaviour however I cannot work out how to set it up and there doesn’t seem to be any documentation or instructions around. I am uploading a csv then I need to insert the data into the a MySQL table. I have the upload working as required.NOTE: the csvimport behaviour is part of the cakeDC utils plugin: https://github.com/CakeDC/utilsI have this in my upload modelvar $actsAs = array(‘Utils.CsvImport’);Within my upload controller I have this (after the file

  • thaJeztah
    php cakephp-1.3 payment
    This is a specific iDeal question; I keep getting the SE2700-error eventhough my certificates are valid and created correctly. The certificate is also uploaded to the aquirer (ING bank) and i’ve downloaded and added the aquirer’s certificate as well. The merchantReturnURL doesn’t have any special characters (http://www.04dertien.com) and the merchant ID is valid.Is there any way the expose_php setting might be involved?This is the iDEAL error:DOMDocument Object ([doctype] => [implementation]

  • Jason Plank
    cakephp-1.3
    I am using spark_plug in my cakephp project and I am having this error when I view my app from a guest account:Fatal error: Uncaught exception ‘Exception’ with message ‘User::authsomeLogin() is not implemented!’The website works fine when I am logged in, and I have tried a lot, but still have no idea what’s going wrong. Can somebody help me with this? I will be thankful.

  • user1080247
    php cakephp cakephp-1.3 cakephp-1.2
    i created custom helper to build dynamic menu and i need to use this helper in all my site pages so i put the code to show menu in element and include it in default.ctp like this<?php echo $this->element(‘menu’); ?>,, but the default.ctp not defined the helper so how to define this helper in all views it give me this errorsNotice (8): Undefined variable: data [APP\views\elements\menu.ctp, line 5]Warning (2): Invalid argument supplied for foreach() [APP\views\helpers\tree.php, line 28]

  • Juhana
    cakephp cakephp-1.3
    I have the following codes, I added the debug and this is the data that I am able to retrieve from the database. I wish to display the [‘User’][‘firstName’] and also the [‘Passion’][‘passion_tag’] in the view page, how do I do it? I am facing error such as: Notice (8): Undefined index: passion_tag [APP\views\searches\simple_search.ctp, line 127][5] => Array([User] => Array([id] => 41[password] => 2b4a3cf55ddf9b15e161aeba3540a75ddd6ea872[firstName] => Ming Xin[lastName] => Toh[e

  • John
    .htaccess cakephp cakephp-2.0 cakephp-2.3 cakephp-appmodel
    I am getting the syntax error commented code. Can some have idea, why this error comesError: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ redmine/app/View/Welcome/index.ctp Line: 4<h2><?php $this->Candy->html_title(__(‘Home’)) ?></h2><div class=”splitcontentleft”> <!– <%= textilizable Setting.welcome_text %> –> <?php echo $this->Candy->textilizable($Settings->welcome_text) ?> <?php if (!empty($news)): ?> <div class=”

  • agit
    php cakephp cakephp-appmodel
    I have most of the app working correctly. Heres the problem: I am trying to edit info in the model for a parent model on a beforeSave/AfterSave function. So I have the accosiations set up Record belongsTo Store, and Store hasMany Records.I am in the records model/controller and on save am wanting to edit the store DB entry “volume” to change the number to signify that there are less avliable due to adding the new record.RecordsConroller.phppublic function add() {if ($this->request->is(‘pos

  • teresko
    cakephp associations cakephp-2.0 cakephp-appmodel
    I’m using cakePHP 2.0 afterFind() callback to perform calculations on database values before it is displayed.I have three models – Materials, Products and Quotes.Each product has a material and calculations are performed in the Product afterFind callback using this association, specifically with the line:$results[$key][‘Product’][‘material_cost’] = $results[$key][‘Product’][‘material_mass’] * $val[‘Material’][‘cost’];with $val[‘Material’][‘cost’] referring to the associated material.All fine so

  • teresko
    cakephp cakephp-2.1 cakephp-appmodel
    Mycakephp version is 2.1.1.i am trying to save the associated model manually using saveAll() functionModelEmployee HasOne Address Employee Belongs to Departmentso table employees(first_name,last_name,age,sex,department_id)addresses(first_line,second_line,city,state,employee_id)now employee creation add.ctp has a form which receives input for employee and addressi know$this->Employee->saveAll($this->request->data);this will save the models but i want to save the association manually i was going t

  • teresko
    php cakephp cakephp-2.1 cakephp-appmodel
    I moved a website (cakephp 2.1) from a test server ( PHP verson 5.3.10 ) to the live server (PHP verson 5.3.17). In the new situate all my code started to complaine about undefined indexes. When debugging an array I see that the array indexes became numbers instead of the Model names!? What can be the problem of that I use the exact same installation of cakephp?Below the 2 examples of arrays.this is how the array should be.Array ([0] => Array([Post] => Array([id] => 152[menu_item_id] =&

  • teresko
    cakephp cakephp-1.3 cakephp-appmodel
    Does anyone knows how to get table name from model name? Also I want to get all column names and its types of that model/table name. Is it possible to get such details of given model name?Thanks.

  • teresko
    cakephp-2.0 cakephp-appmodel
    For reference, please visit this page here. When trying to get a view display on one particular model, I am getting an undefined index error. Specifically, any data from my Coupon model. Here is my controller code:public function seafood() {$this->paginate[‘Restaurant’]=array(‘limit’=>9,’order’ => ‘RAND()’,’contain’=>array(‘User’=>array(‘id’, ‘user_name’),’Coupon’=>array(‘id’,’description’,’expires’,’end_date’,’promo_code’,’restaurant_id’)),’conditions’=>array(‘Restaurant

  • teresko
    php cakephp cakephp-appmodel
    Possible Duplicate:PHP: “Notice: Undefined variable” and “Notice: Undefined index” Many people have asked questions regarding the “Notice (8) Undefined Index” error message but none of the solutions are working for me. I’m not sure if my model relationships are set up correctly. Please advise. I’m getting the undefined index error on the ARTICLES INDEX.CTP page and it says that “Avatar” is the undefined part.On my USERS VIEW.CTP page I echo $this->Custom->UserAvatar($article[‘User’][‘Ava

  • teresko
    cakephp cakephp-appmodel cakephp-2.3 mysql-error-1054
    I’ve got the following find() function$this->User->find(‘all’,array(‘conditions’ => array(‘User.id’ => $this->Auth->user(‘id’)),’fields’ => array(‘User.id’,’UserRole.id’) ));And the following associations are defined// UserRole.php class UserRole extends AppModel {public $belongsTo = array(‘User’ => array(‘className’ => ‘User’,’foreignKey’ => ‘user_id’)); }// User.php class User extends AppModel {public $hasMany = array(‘UserRole’ => array(‘className’ => ‘User

  • teresko
    cakephp cakephp-1.3 cakephp-appmodel
    I have two tables: internet_access_codes and radacct. The internet_access_codes hasMany radacct records. The join is internet_access_codes.code = radacct.username AND internet_access_codes.fk_ship_id = radacct.fk_ship_idI created 2 models and wanted to use $hasMany and $belongsTo respectively so that the related radacct records would be pulled when getting and internet_access_codes record.Here’s the code:class InternetAccessCode extends AppModel{ var $name = ‘InternetAccessCode’; var $hasMany

Web site is in building