cakephp

How to print line break in cakePHP?

Hi all, How do you print a new line break in CakePHP. I have tried this out: echo "<b>\nhelloworld\n</b>"; instead of printing the it into three separate lines like this way: <br> helloworld </b> it just printed in this way when I viewed the HTML source code: <b>helloworld</b> ...

Custom method, related to model

Hi all, Can you help me how to develop custom methods in CakePHP framework. I found this code in stackoverflow, but it's global, it's not "model related". Can you help me with this? Thank you in advance! ...

List CakePHP File Upload error codes.

Anyway, can anyone give me the error code definitions for when files are uploaded in cakePHP. So my $this-data contains something like this, Array ( [file] => Array ( [name] => cake.jpg [type] => image/jpeg [tmp_name] => /tmp/hp1083.tmp [error] => 1 [size] => 24530 ) ) What does [err...

cakephp lookup value if not in database

I'm stll relatively new to cakephp (1.3) and struggling with where to put the code to do the following. I want to display fields from a database (as usual) but, if the value for one of the fields is null, I want to look up the value using a web service and, if the request is successful, write the returned value to the database before re...

cakePHP "session" is not returning session ID

Hello Experts, I am into development of a cakePHP based web application. Here are my core.php settings for session handling Configure::write('Session.save', 'database'); /** * The name of the table used to store CakePHP database sessions. * * 'Session.save' must be set to 'database' in order to utilize this constant. * * The t...

CakePHP TranslateBehavior is driving me crazy!

Hi everyone. I use CakePHP 1.3.2 with the integrated Translate Behavior. The translations I save my several models in each table. Example: class Page extends AppModel { var $name = 'Page'; var $actsAs = array( 'Translate' => array('title', 'subtitle', 'menu') ); var $translateModel = 'PageI18n'; ... } Now... a...

MySQL/CakePHP DB Design Question

Our real estate application has a table, Events, which has historically been linked to the Homes table via an Event.homes_id column. Recently, for the first time, we added an event type which is not connected to a home, but a realtor. The question: is it good practice to now add a realtor_id column to the Events table? Something in me...

Is this overkill, or good use of CakePHP's HTML helper?

I just reformatted the default layout of my CakePHP application. I eliminated as much in-line html as possible by putting almost everything inside the html helper methods. It was fun, but I'm wondering what benefit I've gained from this exercise, if any? <?php $output = implode("\n", array( $html->docType(), $html-...

Why am I getting an undefined property error when my relationships seem correct?

I'm having a slight problem that I can't figure out, but should be really simple. I have the following model structure in my cakePHP (1.3) app: ProspectiveQuote [hasMany] QuoteUnit [belongsTo] Unit but in my ProspectiveQuotesController the line: $this->ProspectiveQuote->QuoteUnit->Unit->find('list'); gives me the following error:...

CakePHP update field value based on other value in same row?

I have been trying to figure out how to do this and it seems that its not something that many people are trying to do in cakephp or I am just completely misunderstanding the documentation.. I am using the following query below to get a field value so I get a value where the "findbycreated" is 0... this part works fine $unregisteredemail...

Methods of a "belongs to" and "has many" relationships

Let's say that I have two tables in my database: users countries I have two defined relationships on each user belongsTo a country and each country hasMany users.. (CakePHP model relationships) And I want to crate the model findUsersFromCountry($countryID) in wich class/model this method will be? It must be inside the User model or t...

CakePHP Form Helper just generated too much code for me.

Hi all I am using cakePHP. I used the cakePHP built-in Form Helper to generate an input text box: echo $form->input('quote', array('label'=>'Post Number', 'class'=>'')); But when I looked at the HTML source code, I found out these: <div class="input text"> <label for="ReplyQuote">Post Number</label> <input name="data[Reply][quote]" ...

Search receiver ID by the USER ID first and locate the data by the receiver ID

Hi all, I am using cakePHP 1.26. I got a simple Table with some data in my localhost Database: user_id | message | receiver_id ----------------------------- 1 | helloworld | 12 2 | hi there | 12 Let say the system now received the $userid from a user. The user only got the user ID. He wants to search all the message ...

Using CakePHP, how do you hide certain elements of a page from a user if they are logged in?

How can I hide our main nav and use it as the home page but only for logged in users? The following is the code for the slideshow. The MENU is an element though. Should they both be in the element file together? Before I attempt to hide when logged in? File /elements/nb_menu_home.ctp reads: <script src="/js/loopedslider.js" type="text/...

How to use SEO urls in CakePHP without the ID?

Hello, Is there a simple way to route my URLs without showing the ID in the URL. For example i have: www.mywebsite.com/id-article-title.html and i want only www.mywebsite.com/article-title.html Regards ...

Cake PHP Fatal Error (256)

I have just created an application using cake bake and when I run it I get the screen that says 'Sweet, myApp got baked' but there is no styling on it and at the bottom i get the following error: Fatal Error (256): ConnectionManager::getDataSource - Non-existent data source default [CORE\cake\libs\model\connection_manager.php, line 102]...

Cakephp isUnique validation is not triggered on one field, but works on another

When I save the information from a registration form I have some validation rules on the username and email fields (I've pasted the rules below). Validation is called automatically with the saveAll() function. The problem is that the isUnique rule on the username field doesn't work at all (doesn't return any error). The other rules for ...

CakePHP: MeioUpload Behavior

Hello. I would like to use the [MeioUpload Behavior][1] for uploading documents like PDF, DOC, XLS etc. but I get an Invalid file type error. My Upload Model looks like this: class Upload extends AppModel { var $name = 'Upload'; var $actsAs = array( 'MeioUpload.MeioUpload' => array( 'upload_file' => array( 'd...

Select Tag with a few options containing multiple values in cakePHP

Hi all, I am using cakePHP 1.26. I am designing a Select Tag with a few Options, and each of the options will contain multiple values. Yet, there is not only one way to do it: Method 1: <select name=""> <option value="[0,1,2,3]">Option one</option> </select> Method 2: <select name=""> <option va...

How to the data available in a 4th column in cakephp?

Hi there, Currently i'm having a problem. I want to access the data available in the 4th table of my DB. Click here to see the db image I have the tables in this way: Categories --> Categories_Companies --> Companies --> Affiliates Like it shows in the image i'm on the categories and in the Categories view (views/categories/view.ctp)...