Re: Alternating Row Colors

2006-08-21 Thread John Zimmerman [gmail]
dangit, dangit, dangit..I need to research the helpers more.Thanks for the snippet, I will go back and recode the appropriate sections of my code.On 8/20/06, 
sicapitan [EMAIL PROTECTED] wrote:
AD7 is right, tablecells does this automatically, and you can set theclaternating colours$html-tableCells($tr, array('style'='background:#E4E4E4'),array('style'='background:transparent'));

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: Cross Application Sesssion

2006-08-21 Thread Mandy Singh
:)

nate - i had already tried that.

basically, i use the same db as used by rdBloggery.

but my application runs in /app/ and the blog in /rdBloggery/

even wheni was storing sessions in the db, i was not able to auto log the person into rdBloggery if he already logged on in my application in /app/.

when i work off the computer at home it works, when i do this from office computer it doesn't.

i m going mad!! :)

thanks,
Mandy.
On 8/19/06, nate [EMAIL PROTECTED] wrote:
Mandy, that's because I wasn't on IRC ;-)in app/config/core.php, there is a setting called CAKE_SESSION_SAVE,
set that to 'database', and load the SQL fromapp/config/sql/sessions.sql into your database.Then, if you includethe same database in both applications, you should be able to sharesession data.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: Cross Application Sesssion

2006-08-21 Thread Mandy Singh
i m thinking of reading the chapter on plugins and see if i can move rdBloggery under /app/plugins though...

On 8/21/06, Mandy Singh [EMAIL PROTECTED] wrote:


:)

nate - i had already tried that.

basically, i use the same db as used by rdBloggery.

but my application runs in /app/ and the blog in /rdBloggery/

even wheni was storing sessions in the db, i was not able to auto log the person into rdBloggery if he already logged on in my application in /app/.

when i work off the computer at home it works, when i do this from office computer it doesn't.

i m going mad!! :)

thanks,
Mandy.

On 8/19/06, nate [EMAIL PROTECTED] wrote:
 
Mandy, that's because I wasn't on IRC ;-)in app/config/core.php, there is a setting called CAKE_SESSION_SAVE, 
set that to 'database', and load the SQL fromapp/config/sql/sessions.sql into your database.Then, if you includethe same database in both applications, you should be able to sharesession data.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: User Bar Logic

2006-08-21 Thread AD7six


Simplerules wrote:
 No matter what I do it won't work here is the code:

//Get User Data;
$Profile = $this-Session-read('User');

if(isset($Profile['Username']))
{
  $this-set('logged_in', TRUE);
  $this-set('username', $Profile['Username']);
} else {
  $this-set('logged_in', FALSE);
   }
 }

 and no matter where I put it I get:
From the code, why not do
$Username = $this-Session-read('User.Username');
if($Username) {
 ...

Where /are/ you putting it, and are you getting this error on every
page request or just a few (like just your static pages, or just your
error messages etc.)?

Cheers,

AD7six


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Pagination for hasMany assocation

2006-08-21 Thread AD7six

Hi All,

nate wrote:
 var $paginate = array('limit' = 20, 'order' = ...); // Anything you
 can pass to Model::findAll can be set here
Is it going to be possible to specify which relationships are included
in the main model query in 1.2, or to specify constraints for
subsequent queries (I´m guessing it is)? If not, as is the present
case constraints for hasMany and HABTM relationship tables won´t be
possible to include - unless something else has changed..?

Tease me, tease me :).

You can work around it, but it´s a bit messy - Query the sub table,
resort the array apply any kind of filtering and then get the array
items that correspond to your pagination values. I have some example
code for this somewhere..

Cheers,

AD7six


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Cross Application Sesssion

2006-08-21 Thread AD7six

Hi Mandy,

Plugins will 'suffer' the same problem as a seperate app, I wrote a
short blog on the topic and how to work around it. It's possible that
the same approach would work for multiple apps, haven´t tried that.

http://www.noswad.me.uk/blogs/view/28

Cheers,

AD7six
PS. I´d welcome comments regarding any problems this may cause.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: url and routing

2006-08-21 Thread teemow

it would be great to have some kind of outgoing dispatcher method. so
that controller-redirect and all the helpers translate the urls. then
we could have one place to define the translation of the urls and one
to map the english urls to controller methods.

if you follow the concept of degradable ajax in your application in
most of the cases it is possible to use the url of the form action or
the href of a link in your javascript.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Help me with my logic please

2006-08-21 Thread [EMAIL PROTECTED]

Hello fellow bakers!

first of all I'd like to tell you that I am an experienced php
developer for years, firstly with plain procedural way, last year OOP
and now I started baking with cakePHP, so I am really new to MVC
concept.

I decided that my first baked application would be a classifieds
system, but not a generic one... I am going for used cars classifieds.

Firstly I defined the database structure. I will list you some basic
tables to show you what I have in mind:


table: companies
table: users
table: user_favorites
table: classifieds (id, user_id, company_id, type, created, modified,
status)
table: photos
table: cars
table: cars_specs
table: classifieds_cars
table: classifieds_others

now,
a user can belong to a company (not a must though)
user can have many classifieds
user can have many favorites (favorite classifieds)

a classified can be posted by a user or a company

There are many classifieds types... two basic though: classifieds cars
and classifieds others...

So this is basics... hope I have explained myself ok.

Now how to do the logics of the site.
It depends on what type of classified we are dealing with...
(cars,others)
so do I need to make the controller logics for only classifieds (delete
classified, add photo, etc - the logics that is the same for both
types), then cars (unique methods just for cars) and others (unique
methods for others) or just classifieds_cars, and classifieds_others
(separated logics)?

and I you suggest me the first option (the common logics)... how do I
manage to combine those? common+cars and commons+others ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Req ITRec/CitrixEngg/DBA/J2EEDev/.NetDev/DelphiProg/COBOLProf/GraphicDsgn/EE/ICE/CivilEngg/SALAdmin/CreditCardProf.......

2006-08-21 Thread freshers/experienced





Hi Dear 
Members,

FOLLOWING R THE JOBS OF THIS 
WEEK:



  
  
 
Job Title
Job Posted By
  
IT 
  Recruiter
keriosolutions.inc
  
Req-0304 -Microsoft / Citrix System Engineer
keriosolutions.inc
  
Req-0285 - SQL / Oracle DBA
keriosolutions.inc
  
J2EE
sagittus Solutions Pvt Ltd
  
Business Development Manager
Emergys Software Pvt Ltd
  
Opportunity for .Net with_ GCI,Microsoft
YS Consulting
  
Microsoft SQL Database Administrator for UAE
Vinirma Consulting Pvt. Ltd.
  
Urgently Required Credit card Professional For UAE
Vinirma Consulting Pvt. Ltd.
  
Urgently Required Delphi Programmer For Qatar
Vinirma Consulting Pvt. Ltd.
  
JAVA JLPT
Infitech Global
  
Urgently Required Tandem CobolProfessional For UAE
Vinirma Consulting Pvt. Ltd.
  
Required Oracle Application Database Administrator
Vinirma Consulting Pvt. Ltd.
  
Req 
  Graphic Designer
Anand Rathi 
  
Electrical Engineer
Iron Ring Staffing Solutions I
  
Electrical Designer
Iron Ring Staffing Solutions I
  
Instrumentation and Control Engineer
Iron Ring Staffing Solutions I
  
Planner and scheduler
Iron Ring Staffing Solutions I
  
Junior Municipal Engineer/Technologist
Iron Ring Staffing Solutions I
  
Need Microsoft SQL Database Administrator For UAE
VAM SYSTEMS FZC
  
Need Credit card Professional For UAE
VAM SYSTEMS FZC
  
Mortgage Originator
National Lending Corporation
  
SAS 
  progammer
marlabconsultants
  
Experienced Content Developer
Softech
  
Web 
  Developer / Web Programmer
Softech
  
Graphic Designer
Softech
  
Web 
  Designer
Softech
  
Flash Rich Media Application Developer
Softech
  
Senior Developers
Mumbai Based IT Company
  
ASST.OPERATIONS MANAGER
Inforide Technologies 
  
NETWORK/ SYSTEM ADMINISTRATOR WITH1+ EXP
Inforide Technologies 
  
BUSINESS DEVELOPMENT EXECUTIVES NEEDED FOR MNC
Inforide Technologies 
  
'Business System Analyst'Sap,Java Architect'
ADEAQUARE INC
  
J2EE professional
Raqmiyat, llc
  
HR 
  - Executive
Added Values
  
Testing requirement
Added Values
  
embeded
techcomsolutions
  
embeded systems
techcomsolutions
  
HR
STC TECHNOLOGIES
  
Cement Plant Specialist
MTMM
  
Req 
  Java Software Engineer
Venturesofttech
  
career counselor
STC TECHNOLOGIES
  
Req 
  Telecom Engg
RLTD
  
Software Engineer 
Fore-D Tech
  
Sap 
  BW Basis Technical Consultant
AikonTechnologiesInc



PLS APPLY ONLINE ON www.net4professionals.com


*Looking For Better 
Jobs/Employee?

-Search 
Jobs/Resumes and Apply Online/Call 4 Interview FREE

-Browse 
Interveiw Calls Free
-Employers Can Post 5 Jobs Free And Also Win Free 
Gifts
http://www.net4professionals.com
(A2Z HR INFO SERVICES INDIA)THE 
COMPLETE e-JOBS SOLUTIONS PROVIDER...

REGARDS

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---






othAuth: logging in as other user + warning when permissions not sufficient

2006-08-21 Thread [EMAIL PROTECTED]

Hey guys, i just installed othauth, injected the logic in
app_controller, created some users, groups, incremented $gid a bit and
set $strict_gid_check to false in the component configuration (yes i
know this is not a clean method, i will fix this later and pass the
right stuff to the login method)


but now i have 2 questions

1)i can login both as user A, or as user B, but when i'm logged in as A
i can't login as B without logging out first (and vice versa).  is this
a bug, or a feature? ;-) any way i can enable upgrading accounts
without making dirty hacks in oth's code?

2) say i'm not logged in and request to do a protected method, so i get
the login prompt, and enter the (valid) login information for a user
who's permission level is not sufficient for the action.  what happens
now is that i'm redirected back to the login page.  anyone knows a nice
method to return to the loginpage, but show also a message permissions
not sufficient for this user or something like that?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread Chris Hartjes

Isn't that info available in $data['Category']?  Given the
relationships you've established I think it would be there.

On 8/21/06, ShepherdWeb [EMAIL PROTECTED] wrote:

 Color and Product are hasAndBelongsToMany to each other

 Product belongsTo Category

 Category hasMany Product

 I'm using this code to show products by color:


 $this-Product-Color-id = $color_id;
 $data = $this-Product-Color-read();
 $this-set('products', $data['Product']);

 this returns this array:

 Array
 (
 [0] = Array
 (
 [id] = 51
 [title] =  Pink Polka dot Headband
 [description] = This is our best selling headband!  We
 start with a stretch cotton headband that is oh so comfy, then top it
 off with an adorable light pink and white polka dot grosgrain bow. This
 bow has a pink and white knotted center.  This headband is a classic
 and one your little girl will wear for years! Fits ages 4 months - 4
 years.
 [inventory] = 2
 [price] = 4.99
 [category_id] = 1
 [sale_date] = -00-00
 [sale_price] = 0
 )

 [1] = Array
 (
 [id] = 52
 [title] = Double Ruffle Satin Bow
 [description] = How could you live without this one?
 Bowhead Babies favorite bow of all, the double ruffle satin bow.  This
 bow is perfect for dresses and casual play clothes.  It has a matching
 satin knotted center and covered scissor clip back.  This bow measures
 3 and is great for newborn to toddler girls.  It looks great in a lace
 headband or in pigtails! Look at our 5 piece set deal!
 [inventory] = 5
 [price] = 3.99
 [category_id] = 1
 [sale_date] = -00-00
 [sale_price] = 0
 )

 )

 I would like to be able to return category.title to the view also.  How
 do I do this?


 



-- 
Chris Hartjes

The greatest inefficiencies come from solving problems you will never have.
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Saving with hasMany

2006-08-21 Thread Rolo D. Monkey

Perhaps I need to be more specific.  I am importing the data from a
.csv file, so I am building the data structure myself, and the
information from the Manual does not explain how to create a data
structure for multiple hasMany records. So far I have managed to save
Member records, and I had no trouble creating links to Categories
through a hasAndBelongsToMany association.  I have tried both

$this-Member-Individual-save($record);

and

$this-Individual-save($inds_record);

and neither worked, so there must be something wrong with my data
structure or my code.

Here is one data structure, I tried:

$record = array(
  Member=array(
id = ,
 ...
Category=array(
  Category=array(
[0] = $category_id[0],
...
  )
)
Individual=array(
  id = ,
  individual_name = $inds[$i]
)
  )
)

and it didn't work.  Also even if it did work,  what would happen if I
looped through $i?  I suspect I would end up with a bunch of duplicate
Member records.

So, I tried just saving Individuals:

$inds_record = array(
  Individual=array(
id = ,
individual_name = $inds[$i]
  )
)

and that didn't work either.  I haven't starting using
getLastInsertId() yet, but I am going to add that today, but I suspect
I am just missing something simple.  Any suggestions?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: 's' vs. 'ies' plural for table names

2006-08-21 Thread John David Anderson (_psychic_)


On Aug 21, 2006, at 9:21 AM, Zoltan wrote:


 A bit of a newbies question here, but what is the correct way to  
 handle
 tables like 'city', should I name it 'cities' or 'citys'?

Have you tried it?

Should be 'cities'.

-- John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: 's' vs. 'ies' plural for table names

2006-08-21 Thread Zoltan

Yes, I tried it and it seemed to work at first, then got some errors
about missing controllers. This was about a week ago, but going from
memory I used something like:

class City extends AppModel
{
var $name = 'City';
}

and

class CitiesController extends AppController
{..}

Does this look correct?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: 's' vs. 'ies' plural for table names

2006-08-21 Thread John David Anderson (_psychic_)


On Aug 21, 2006, at 9:33 AM, Zoltan wrote:


 Yes, I tried it and it seemed to work at first, then got some errors
 about missing controllers. This was about a week ago, but going from
 memory I used something like:

 class City extends AppModel
 {
 var $name = 'City';
 }

 and

 class CitiesController extends AppController
 {..}

var $name = 'Cities';

(always a good idea to include $name, even in  your controllers).

 Does this look correct?

Looks good to me - are you still getting errors?

-- John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Intercepting dispatcher's routes

2006-08-21 Thread jez

Thanks nate, lots of help.

Jez.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Template Extension and Smarty.

2006-08-21 Thread Brian French

Is there a way to set it in the config for the app?
(i use dreamweaver and want to keep the code highlighting, etc.)

mouth wrote:
 ad 1)

 create file app/views/test.php with content:
 ?php
 require_once 'cake'.DS.'libs'.DS.'view'.DS.'view.php';
 class TestView extends View {
 var $ext = '.test';
 }
 ?
 and in Your controller You have to set

 var $view = 'Test';

 ad 2)

 try visit http://cakephp.org/search?q=smarty

 BTW: You must have serious reasons for using Smarty in CakePHP IMHHO.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Template Extension and Smarty.

2006-08-21 Thread mouth

Brian French wrote:
 Is there a way to set it in the config for the app?

Just make file app/app_controller.php with this content:
?php
class AppController extends Controller {
var $view = 'test';
}
?

 (i use dreamweaver and want to keep the code highlighting, etc.)

I don't understand what is matter :(


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Template Extension and Smarty.

2006-08-21 Thread Brian French




Dreamweaver has highlighting and other bells and whistles built into it
which i like.
they are based on the extension of the file you are editing. if im
editing an html file, it highlights the html as well as if i was
editing a php or asp, etc. file. Dreamweaver doesn't recognize the
'thtml' and just displays this as regular text.

Looking at your example below, does this change the extension to
'index.test'?

mouth wrote:

  Brian French wrote:
  
  
Is there a way to set it in the config for the app?

  
  
Just make file app/app_controller.php with this content:
?php
class AppController extends Controller {
var $view = 'test';
}
?

  
  
(i use dreamweaver and want to keep the code highlighting, etc.)

  
  
I don't understand what is matter :(




  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---





Join Table in Conditions of a findAll

2006-08-21 Thread [EMAIL PROTECTED]

I have a database schema with categories and products that are joined
with categories_products table. This makes it so a product can be
assigned to multiple categories.

I would like to find all of the products that belong to a category.

I've tried:

$this-Product-findAll(array(CategoriesProduct.category_id='$id'),
$fields, null, 10, $page, 1);

but I get an unknown column CategoriesProduct.category_id error.

Is there anyway that I can do this besides writing my own query?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: 's' vs. 'ies' plural for table names

2006-08-21 Thread Samuel DeVore
usually when I am starting a site that might have funky plurals I make a page that calls the Inflector class with the various calls for the words to see what cake thinks the plurals will be, if they are not what I expect, I either add them in the config/inflectors.php or change my thinking ;)
On 8/21/06, nate [EMAIL PROTECTED] wrote:
Our inflector is pretty darn good, and can properly inflect mostEnglish words without any extra hinting.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Let user submit multiple records

2006-08-21 Thread mutabor

Hello. I have a model called 'Room'. I need to let user submit as many
rooms at once as he wants by placing javascript 'Add room' button.
Each time user press this button it pastes one more set of fields to
let user enter another room information. And in the end there is submit
button which submits all rooms at once.

This way I have some sets of fields with equal names in my view and
Cake's controller  eats only the last one's data :(
Please, tell me what is the best way to handle this situation with
Cake? I have looked though groups but wasn't so lucky to find any
information.

Thank you.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Let user submit multiple records

2006-08-21 Thread Mikee Freedom

Morning Mutabor,

I did a similar thing with Config values. I printed all of my Config
values on a single page and allowed the user to edit them at one time.
When creating the form I employed non-standard CakePHP form input
naming conventions and then interpreted these at the controller level.

e.g.
input name=data[0][name] type=...
input name=data[0][size] type=...

input name=data[1][name] type=...
input name=data[1][size] type=...
etc

Then you can use a `for` loop to cycle through your form data create
the correctly formatted data array based on your form data and use:

foreach ($this-data as $data) {
$this-Room-save($data);
}

A very simplistic explanation but do you understand what I mean?

On 22/08/06, mutabor [EMAIL PROTECTED] wrote:

 Hello. I have a model called 'Room'. I need to let user submit as many
 rooms at once as he wants by placing javascript 'Add room' button.
 Each time user press this button it pastes one more set of fields to
 let user enter another room information. And in the end there is submit
 button which submits all rooms at once.

 This way I have some sets of fields with equal names in my view and
 Cake's controller  eats only the last one's data :(
 Please, tell me what is the best way to handle this situation with
 Cake? I have looked though groups but wasn't so lucky to find any
 information.

 Thank you.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Let user submit multiple records

2006-08-21 Thread mutabor

Hello Mike.

Thank you very much for the quick reply. This is definitely a nice and
elegant way to handle it. I think I should use it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Cookies

2006-08-21 Thread Simplerules

I am using this to set cookies:
setcookie($Name, $Value, time()+$Length)
and it works, except the cookies are not accessible in CAKEPHP.

The cookies (unlike the CAKEPHP cookie) are set to cake_1.1.7.3363/
while CAKEPHP is set to cake_1.1.7.3363 ; When I do a print_r($_COOKIE)
I only find the CAKEPHP cookie.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Let user submit multiple records

2006-08-21 Thread Mikee Freedom

no worries.

if you run in to trouble you might also have to look at using:

$this-Room-create();

this method prepares your model for insertion each time. otherwise
once you use the model to save data it sets the id of that model and
then each subsequent save will be an update instead of an insert.

something like:

foreach ($this-data as $data) {
   $this-Room-create();
   $this-Room-save($data);
}

if i'm wrong i'm sure someone will correct me.

On 22/08/06, mutabor [EMAIL PROTECTED] wrote:

 Hello Mike.

 Thank you very much for the quick reply. This is definitely a nice and
 elegant way to handle it. I think I should use it.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Join Table in Conditions of a findAll

2006-08-21 Thread ShepherdWeb

@Jimmy -

Check out this WIKI entry:

http://wiki.cakephp.org/docs:method:read

I hope this helps!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

Nope.  It's not there.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Raw Query

2006-08-21 Thread Simplerules

How do I do a raw SQL query?

I need to access a table called 'Users', which belongs to
UsersController, in a component Logins - is there a way to do this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Raw Query

2006-08-21 Thread John David Anderson (_psychic_)


On Aug 21, 2006, at 4:48 PM, Simplerules wrote:


 How do I do a raw SQL query?

If at all possible, I would use model functions, but you can also  
always use the query() and execute() functions of the model as well.

 I need to access a table called 'Users', which belongs to
 UsersController, in a component Logins - is there a way to do this?

Have you created a User model?

-- J



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Raw Query

2006-08-21 Thread Simplerules

Yes, it has a Model.

'Users' is a fully working area, but I need to access some data from
the table Users in this component.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Raw Query

2006-08-21 Thread John David Anderson (_psychic_)


On Aug 21, 2006, at 4:55 PM, Simplerules wrote:


 Yes, it has a Model.

 'Users' is a fully working area, but I need to access some data from
 the table Users in this component.

Just to clarify, are you using Cake vocabulary here?

Is your question that you want to know how to access and use your  
User model from a Cake component  you are building?

-- John

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Join Table in Conditions of a findAll

2006-08-21 Thread ShepherdWeb

I'm working on a similar scenario right now.  I haven't found a
solution yet.

Maybe some seasoned Cake veterans will chime in on this


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Raw Query

2006-08-21 Thread Simplerules

Yes.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Help me with my logic please

2006-08-21 Thread ShepherdWeb

You'll end up using $this-requestAction() for logic that spans
multiple models.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



View subdirectories names ... problem

2006-08-21 Thread purepear

Hi,
my problem:

I have a controller  called -  ProductCatsController with an action
-  admin_index
I have a /views/productcats/admin_index.thtml file

But the this url   /admin/product_cats/ says  Missing View in the
title.. and some
Notice: Undefined variable: javascript in  
Fatal error: Call to a member function link() on a non-object in
..

I'm sure that the action is executed... the SQL queries in it too
but i dont know why cakePHP can't find my view...
I tried to rename /views/productcats/to /views/product_cats/
 but still the same.
I have other controllers that work with the admin path ... so i dont
think this is the problem.
I think it's because of the controller name btw my   model name is
ProductCat and set the var $Name   in the controller..

anybody.. ? :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: View subdirectories names ... problem

2006-08-21 Thread purepear

Is there a way to see what is the View file (and its path) that cakePHP
is trying to render in this action ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: View subdirectories names ... problem

2006-08-21 Thread DJ Spark

 the problem seems to be you are using some helpers , and you didn't
include the HTML helper, which contains the function $html-link()
 just add the html helper to your controller.
 tell us if it works :)

 spark!

On 8/21/06, purepear [EMAIL PROTECTED] wrote:

 Hi,
 my problem:

 I have a controller  called -  ProductCatsController with an action
 -  admin_index
 I have a /views/productcats/admin_index.thtml file

 But the this url   /admin/product_cats/ says  Missing View in the
 title.. and some
 Notice: Undefined variable: javascript in  
 Fatal error: Call to a member function link() on a non-object in
 ..

 I'm sure that the action is executed... the SQL queries in it too
 but i dont know why cakePHP can't find my view...
 I tried to rename /views/productcats/to /views/product_cats/
  but still the same.
 I have other controllers that work with the admin path ... so i dont
 think this is the problem.
 I think it's because of the controller name btw my   model name is
 ProductCat and set the var $Name   in the controller..

 anybody.. ? :)


 



-- 
[web] http://synapsisdi.com.br
[livesets] http://djspark.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

I found that I can use find() instead of read(), and set recursive = 2
to return category.title, however, this returns way more data than I
need and drastically affects performance.  Not a usable solution.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Error in the Cake Blog tutorial.

2006-08-21 Thread mrbog


I just installed the latest cakephp release and tried doing the cake
blog tutorial.  This one:

http://manual.cakephp.org/chapter/20

Here is the error I got:

Warning: Invalid argument supplied for foreach() in
/www/cakefun/cake/libs/controller/controller.php on line 604

Warning: Invalid argument supplied for foreach() in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1140

Notice: Uninitialized string offset: 0 in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1147

Notice: Uninitialized string offset: 0 in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1149

Notice: Uninitialized string offset: 0 in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1152

Notice: Uninitialized string offset: 0 in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1157

Notice: Uninitialized string offset: 0 in
/www/cakefun/cake/libs/model/datasources/dbo_source.php on line 1160

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/www/cakefun/cake/libs/controller/controller.php:604) in
/www/cakefun/cake/libs/session.php on line 131

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/www/cakefun/cake/libs/controller/controller.php:604) in
/www/cakefun/cake/libs/session.php on line 131


After that, on the page, I get:


CakePHP Rapid Development
List Posts
Actions

New Post

I tried adding a new post, but there are no fields in the form.  I
click new and go back to this page and get the same errors and no new
posts.

I have php 5.1.2. My mysql is 5.0.20 and both are working fine for
other (non cake) php sites on my server.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Join Table in Conditions of a findAll

2006-08-21 Thread DJ Spark

from the cakephp manual, quoted below, you can see how adding a few
parameters to the findAll function you can limit the number of rows
retrieved:
example:
$this-User-findAll('',null, '', 20, 2);
this gets the second page of results, containing 20 items each.

 If you use a variable $page, for example, you may use it in the view
to a 'next' and 'previous' link.
 or you could wait for the cake 1.2 version :

 spark



findAll( $conditions,
  $fields,
  $order,
  $limit,
  $page,
  $recursive);
string   $conditions;
array   $fields;
string   $order;
int   $limit;
int   $page;
int   $recursive;

Returns the specified fields up to $limit (default is 50) records
matching $conditions (if any), start listing from page $page (default
is page 1). $conditions should look like they would in an SQL
statement: $conditions = race = 'wookie' AND thermal_detonators  3,
for example.

When the $recursive option is set to a integer value between 1 and 3,
the findAll() operation will make an effort to return the models
associated to the ones found by the findAll(). The recursive find can
go up to three levels deep. If your property has many owners who in
turn have many contracts, a recursive findAll() on your Property model
will return up to three levels deep of associated models.

-
spark


On 8/21/06, ShepherdWeb [EMAIL PROTECTED] wrote:

 I'm working on a similar scenario right now.  I haven't found a
 solution yet.

 Maybe some seasoned Cake veterans will chime in on this


 



-- 
[web] http://synapsisdi.com.br
[livesets] http://djspark.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

Here's my solution.  It's not the most elegant in the world, but it
gets the job done.  If anyone has a suggestion for a better way, please
chime in.

$categoryData = $this-requestAction('/categories/select/');

$this-Product-Color-id = $color_id;
$data = $this-Product-Color-read();
for ($i=0; $icount($data['Product']); $i++)
{
$catId = $data['Product'][$i]['category_id'];
$data['Product'][$i]['categoryTitle'] = 
$categoryData[$catId];
}
$this-set('products', $data['Product']);

basically, I'm getting the category data, then getting the product data
related to the selected color...and finally looping through the
products and adding the category title.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Raw Query

2006-08-21 Thread Simplerules

So how would I use a function in the model User, from a seperate
component?

:)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Date Format output

2006-08-21 Thread c_doug

Can someone give me an idea of how to output a date in a certain
format? In this case I am trying to only output the month in the view.

Can I add a simple function to:

$a['Post']['created']

to make it output just a month or various date formats?

I have searched but haven't been able to apply what I have found.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Date Format output

2006-08-21 Thread Samuel DeVore

have you looked at the php date function?  http://php.net/date  or you
can do what I did and make a custom helper function that allows one to
custom format dates.  like

function niceShort($date_string, $format='l j F Y', $return = false)  {
$timestamp = $this-Time-toUnix($date_string);
return($this-output(date($format,$timestamp),$return));
//code here
} // END function

this is 'my' version of the niceShort helper that is in the Time
helper  (notice I use some functions from that helper.  I found that I
was doing this enough that I extended the function for my own use.

 This should give you a starting point ;)

Sam D  (the resident old fart)


On 8/21/06, c_doug [EMAIL PROTECTED] wrote:

 Can someone give me an idea of how to output a date in a certain
 format? In this case I am trying to only output the month in the view.

 Can I add a simple function to:

 $a['Post']['created']

 to make it output just a month or various date formats?

 I have searched but haven't been able to apply what I have found.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Date Format output

2006-08-21 Thread c_doug

Thanks, I'll have to try that once I get a little more advanced.

I am trying to apply different variations of PHP date functions to it.

I am hoping to put a simple function around the 'created' variable
above. Something like:
date('mask', created).


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Re: Date Format output

2006-08-21 Thread Samuel DeVore

you need to convert the date string to a unix timestamp before you can
use it in date()  you can use the Time helper function toUnix to
accomplish this or look at
http://us3.php.net/manual/en/function.strtotime.php for the string to
time function.

the unix timestamp is probably your sticker on this

date('mask' $this-Time-toUnix($a['Post']['created']))

should get you closer  (it's all the helper function is doing)

On 8/21/06, c_doug [EMAIL PROTECTED] wrote:

 Thanks, I'll have to try that once I get a little more advanced.

 I am trying to apply different variations of PHP date functions to it.

 I am hoping to put a simple function around the 'created' variable
 above. Something like:
 date('mask', created).


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Date Format output

2006-08-21 Thread Mikee Freedom

don't forget the Time helper

http://manual.cakephp.org/chapter/helpers
http://api.cakephp.org/class_time_helper.html

On 22/08/06, c_doug [EMAIL PROTECTED] wrote:

 Thanks, I'll have to try that once I get a little more advanced.

 I am trying to apply different variations of PHP date functions to it.

 I am hoping to put a simple function around the 'created' variable
 above. Something like:
 date('mask', created).


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



How to test for the current model?

2006-08-21 Thread Bernard Grosperrin

I need some help with something which looks like the cat chasing it's 
tail, to me, but I am a beginner!

I have a component which I call from the default.thtml view, as I want 
it in a sidebar, and that is defined there. But in fact, I would like 
that component displayed/active only when the user is on a specific set 
of controllers(2). Problem is, if I do not put var $components = 
array('mycomponent') in the app_controller, I get an error, because it's 
called from default.

So, how should I test, from the default view, which controller is 
currently in use?
Or is there another/better way?

Thanks,
Bernard


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: How to test for the current model?

2006-08-21 Thread Mikee Freedom

hey dood,

i don't know if this would be the best method but you can access the
controller from your views and layouts via:

$this-controller

so you can check for the controller name

if ($this-controller-name == 'Blahs') {
 display
}

or for the modelClass

if ($this-controller-modelClass == 'Blah') {
 display
}

my knowledge of MVC is fairly new but i tend to access the controller
attributes quite a lot to grab things like the modelClass etc. this
way I can create reusable elements quite easily.

i'm sure there are better ways of doing this, but it works.

cheers,
freedom

On 22/08/06, Bernard Grosperrin [EMAIL PROTECTED] wrote:

 I need some help with something which looks like the cat chasing it's
 tail, to me, but I am a beginner!

 I have a component which I call from the default.thtml view, as I want
 it in a sidebar, and that is defined there. But in fact, I would like
 that component displayed/active only when the user is on a specific set
 of controllers(2). Problem is, if I do not put var $components =
 array('mycomponent') in the app_controller, I get an error, because it's
 called from default.

 So, how should I test, from the default view, which controller is
 currently in use?
 Or is there another/better way?

 Thanks,
 Bernard


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Conditions Reference

2006-08-21 Thread Mikee Freedom

Hey all,

A quick query.

I prefer to include conditions as an array but was curious how to set
conditions other than:

field = 'value'

i.e. Model-findAll(array('field' = 'value'))

Specifically I am trying to grab all records in the last month. But it
would be good to know if there was a quick reference that listed a few
examples.

Anyone know?

I think someone mentioned something about it here in the groups a
short while back but I can't seem to find it.

Thanks again,
Mike

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



hasMany and custom SQL

2006-08-21 Thread Sonic Baker






Hi there,

It seems that Models associated via $hasMany are not done so via JOIN's. Rather, they are called as a separate query with the id of the calling model. Why is this?

This results in some strange behavior when certain conditions in the $fields array are defined.

e.g.
Product hasMany StockedItem

The StockedItem model has fields for buy_price and sell_price.

If I want to get a product with associated StockedItem entries, ordered by profit, I can do either of the folowing:

$data = ""
);
$this-Product-id = $data['id'
];
$modelData = $this-Product-StockedItem-findAll(null
, '*, (unit_price - buy_price) AS profit', 'profit DESC'
);

This will output the 'profit' field as an array, i.e.

Array
(
[0] = Array
(
[StockedItem] = Array
(
[item_id] = 10001
[supplier_id] = 1
[quantity] = 10
[unit_price] = 45.50
[buy_price] = 41.00
[created] = 2006-08-19 23:23:23
[modified] = 2006-08-19 23:23:23
)

[Product] = Array
(
[id] = 10001
[description] = Product10001
[category_id] = 1
[brand_id] = 5
[reorder_level] = 4
[tax_percent] = 21
[image] = no-image.gif
)

[0] = Array
(
[profit] = 4.50
)

)

[1] = Array
(
[StockedItem] = Array
(
[item_id] = 10001
[supplier_id] = 1
[quantity] = 10
[unit_price] = 45.50
[buy_price] = 42.00
[created] = 2006-08-19 23:23:23
[modified] = 2006-08-19 23:23:23
)

[Product] = Array
(
[id] = 10001
[description] = Product10001
[category_id] = 1
[brand_id] = 5
[reorder_level] = 4
[tax_percent] = 21
[image] = no-image.gif
)

[0] = Array
(
[profit] = 3.50
)

)


etc
...
)


Alternatively I can set the 'fields' and 'order' entries in the hasMany array in the model and just issue a findAll on Product. This results in a slightly shorter output but the 'profit' field is still set as an array, i.e
.





Array
(
[0] = Array
(
[Product] = Array
(
[description] = Product10001
[category_id] = 1
[brand_id] = 5
[reorder_level] = 4
[tax_percent] = 21
[image] = no-image.gif
)


[StockedItem] = Array
(
[0] = Array
(
[item_id] = 10001
[supplier_id] = 1
[quantity] = 10
[unit_price] = 45.50
[buy_price] = 41.00
[created] = 2006-08-19 23:23:23
[modified] = 2006-08-19 23:23:23
[0] = Array
(
[profit] = 4.50
)

)

[1] = Array
(
[item_id] = 10001
[supplier_id] = 1
[quantity] = 15
[unit_price] = 46.00
[buy_price] = 42.50
[created] = 2006-08-19 23:25:41
[modified] = 2006-08-19 23:25:41
[0] = Array
(
[profit] = 3.50
)

)

[2] = Array
(
[item_id] = 10001
[supplier_id] = 2
[quantity] = 20
[unit_price] = 46.50
[buy_price] = 46.00
[created] = 2006-08-19 23:26:17
[modified] = 2006-08-19 23:26:17
[0] = Array
(
[profit] = 0.50
)

)

)

)
)

Can anyone tell me why this is happening?
Also, is there a better way to do what I'm trying to do? I would 

Re: Conditions Reference

2006-08-21 Thread Samuel DeVore

$this-Model-findAll(array('field' = '= value'))
On 8/21/06, Mikee Freedom [EMAIL PROTECTED] wrote:

 Hey all,

 A quick query.

 I prefer to include conditions as an array but was curious how to set
 conditions other than:

 field = 'value'

 i.e. Model-findAll(array('field' = 'value'))

 Specifically I am trying to grab all records in the last month. But it
 would be good to know if there was a quick reference that listed a few
 examples.

 Anyone know?

 I think someone mentioned something about it here in the groups a
 short while back but I can't seem to find it.

 Thanks again,
 Mike

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Let user submit multiple records

2006-08-21 Thread Vanchuck

While we're talking implementations, I thought I'd chime in with how I
solved this problem).

My implementation was for editing Translations (I may post about my
i18n implementation in another topic soon enough). One example
specifically is for a user's first and last name (if I'm posting a
message on the Chinese message board of the site, I want my Chinese
name to show up, but if I'm on the English side, I want my English
name). Anyway, a user shouldn't have to go to a complicated separate
page to enter their name in when signing up. The name as usual consists
of 2 fields -- firstname and lastname

I wanted to keep use of the TranslationModel for doing auto error
checking, and so I could continue to use the HTML helper for creating
form inputs, outputing errors, and filling in existing values for the
name inputs, so rather than doing everything manually, I kind of hacked
things a bit.

When the page is displayed a helper outputs a set of inputs for each of
firstname and lastname. The inputs are the visible 'value' text field
as well as various hidden fields for specifying what language it's in,
etc. In the view this is accomplished with a simple 1 line call to the
helper function. Each set of inputs is given it's own enumerated 'fake'
model name, such as  Translation1, Translation2, etc.

When data is submitted, a TranslateComponent is used to check the
submitted data array for models matching Translation#. When it finds
them, it creates a new instances of the TranslationModel, and adds them
to the controller's array of models in $this-modelNames (this is
needed so that the validationErrors array for these fake models are
properly merged and outputted to the view, since Model-render() uses
this array for that).

Upon successful validation of the TranslationModel's and other data,
the translations need to be saved (there are 2 separate saves, so
validation must be validated manually, not just automatically during
the Model-save() call). Another TranslateComponent function steps in
to do this, by executing a loop like Mike wrote about above (and yes,
don't forget the create() call!), to save each of the found 'fake'
models.

If something doesn't validate, then you don't have to do anything-- the
view helper ensures that the error messages and existing values are
properly displayed thanks to the inputs' naming.

The only problem with this is that when I go to save the 2
newly-created translation id's into my User Object, I then have to make
an assumption, that the 1st set of inputs (Translation1) is the first
name, and the second (Translation2) is the last name. Swapping these in
the view will mix things up, so it violates the MVC principle a bit.

I enjoyed reading the other solution provided, and would love to hear
about how others are doing this, I have another similar situation that
I haven't coded yet that will be even more complicated, so if there's
some better solution, it's not too late to save me from the clutches of
my own ignorance!

Cheers.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Conditions Reference

2006-08-21 Thread Mikee Freedom

a that simple.

thanks mate

On 22/08/06, Samuel DeVore [EMAIL PROTECTED] wrote:

 $this-Model-findAll(array('field' = '= value'))
 On 8/21/06, Mikee Freedom [EMAIL PROTECTED] wrote:
 
  Hey all,
 
  A quick query.
 
  I prefer to include conditions as an array but was curious how to set
  conditions other than:
 
  field = 'value'
 
  i.e. Model-findAll(array('field' = 'value'))
 
  Specifically I am trying to grab all records in the last month. But it
  would be good to know if there was a quick reference that listed a few
  examples.
 
  Anyone know?
 
  I think someone mentioned something about it here in the groups a
  short while back but I can't seem to find it.
 
  Thanks again,
  Mike
 
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Re: Conditions Reference

2006-08-21 Thread Samuel DeVore

no worries ;)  open a ticket on the documentation, it should be in
there, but  couldn't find it either ;)

On 8/21/06, Mikee Freedom [EMAIL PROTECTED] wrote:

 a that simple.

 thanks mate

 On 22/08/06, Samuel DeVore [EMAIL PROTECTED] wrote:
 
  $this-Model-findAll(array('field' = '= value'))
  On 8/21/06, Mikee Freedom [EMAIL PROTECTED] wrote:
  
   Hey all,
  
   A quick query.
  
   I prefer to include conditions as an array but was curious how to set
   conditions other than:
  
   field = 'value'
  
   i.e. Model-findAll(array('field' = 'value'))
  
   Specifically I am trying to grab all records in the last month. But it
   would be good to know if there was a quick reference that listed a few
   examples.
  
   Anyone know?
  
   I think someone mentioned something about it here in the groups a
   short while back but I can't seem to find it.
  
   Thanks again,
   Mike
  
   
  
 
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---