RE: generateDate year setting

2006-12-09 Thread Grant Davies

Thanks Nate, I was tempted to do that but was trying not to duplicate
cake functionality if it was already there... thanks a bunch!

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of nate
Sent: Saturday, December 09, 2006 11:56 AM
To: Cake PHP
Subject: Re: generateDate year setting


There's probably a simpler way to do this, but:

$html->selectTag('My/date', array_keys(array_fill(intval(date('Y')),
15, '')))




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Rendering a view for ajax and non ajax

2006-12-05 Thread Grant Davies

Thanks, I ended up solving it using an element and removing the ajax setting 
from the render call, thanks for your help.

grant 



...
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti


-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of AD7six
Sent: Tuesday, December 05, 2006 3:18 AM
To: Cake PHP
Subject: Re: Rendering a view for ajax and non ajax


Hi Grant,

You should not be calling render in your view. To make reusable bits of code, 
you /should/ make use of elements. I don´t quite follow what you mean about 
multiple calls to renderElement, surely the element in this context would 
contain either the form or the table, so at most there would be 2 elements. 
Also, generally speaking, it's a bad idea to specify ajax in a render call in a 
controller ($this->render(x,
'ajax');) That's what the request handler does for you automatically - if 
someone accesses the url for your ajaxed controller action directly (or doesn't 
have js enabled) they are not going to see a layout if you hard code to use the 
ajax layout.

A different way of thinking would be to replace your $this->render in your view 
with echo $ths->requestAction(UrlToDisplayResults); and remove all controller 
logic for creating the table data from your bureauPage action/controller.

The examples below might help (or perhaps some of the other
permutations):
http://www.noswad.me.uk/Pagination/Form
http://www.noswad.me.uk/Pagination/PRG/Ajaxed

You can get the source from the demos tab, note that for the second example the 
view does not make use of elements but it should (in keeping with what I said 
above).

Anyway, HTH or at least gives something to think about.

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no results 
for the google group.
The wiki may contain incorrect info - read at your own risk (it's mainly user 
submitted) :) You may get your answer quicker by asking on the IRC Channel (you 
can access it with just a browser here:http://irc.cakephp.org).




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Rendering a view for ajax and non ajax

2006-12-04 Thread Grant Davies

Sorry I should be more clear..

When the page is first rendered I have a table generated with content in it.

Once the page is up there are some selection boxes to allow you to filter the 
contents of the table.

So the first time the page is rendered there is no ajax call, its just rendered.

When the user selects a filter, I make an ajax call to have the table 
re-rendered without re-loading the page.

So my dilema..

My controller has the method  bureauPage which has a view bureau_page.thml   
This has a div inside it


$this->render('results_table');


When its first rendered it needs to render the table which I could do with 
regular html calls or multiple calls to renderElement.

Now in my code when you apply the filter I need to update the results_table div 
 so in the controller I have

render('results_table', 'ajax');

So if I didn't user $this->render('result_table') in the view bureau_page.thml  
I'd have to have to copies of the results_table php code, one when the page is 
first created, and one when I need to update the div due to the ajax call.

Can you tell me a better way to do this since I may just be going about it all 
wrong.

Cheers
Grant









...
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti


-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of AD7six
Sent: Monday, December 04, 2006 3:17 AM
To: Cake PHP
Subject: Re: Rendering a view for ajax and non ajax


Hi Grant,

It's probably wise to take a step back and look at your code with an eye on 
what methods you should be using. You should not be calling render in your 
view, or was that  typo? Your message implies that you have 
table_contents.thtml and table_content.thtml, but I can´t really make out what 
you have or want to achieve.

Regarding ajax and not: There is no need to create 2 views for the same method, 
irrespective of the contents that is obviously a duplication.
Just include the requestHandler component - you then don't need to do anything 
to have a layout for a normal request, and not for an ajax request. Generally 
speaking, it's unnecessary for controller or view code to be aware of whether 
it's an ajax call or not when processing a request.

HTH,

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no results 
for the google group.
The wiki may contain incorrect info - read at your own risk (it's mainly user 
submitted) :) You may get your answer quicker by asking on the IRC Channel (you 
can access it with just a browser here: http://irc.cakephp.org).

On Dec 4, 4:29 am, "Grant Davies" <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have a view where I need to render the same content when its an ajax 
> call another time when its first page render.  I don't want a 
> duplicate of the table_contents.thtml file even if its uses elements 
> to create itself. So in the table_content.html view file has :
>
> 
> $this->render("table_contents");
> 
>
> and in the controller when I do an ajax update I do :
>
> $this->render('table_contents', 'ajax');
>
> the issue is when you render  a view inside a page causes it to render 
> the view with its layout so it closes the html tag and the body tag at 
> the end of the render call, and anything after is techinically invalid 
> since the html tag has been closed. So my initial page render is 
> actually wrong due to the table_contents being a view file and not an 
> element file.
>
> I know you can use elements for "content" which I do to actually 
> create the details of the table_contents.thml but when the page loaded 
> the first time its table_content div is the same as when its called 
> from ajax and I hate having a duplicate view thml file.
>
> Cheers
> Grant
>
> ...> b l u e t u b e i n t e r 
> a c t i v e..: grant davies
> .: 404.428.6839 (c)
> .: 708-983-1577 (F)
>
> > [EMAIL PROTECTED]
> >http://www.bluetube.com/bti<http://www.bluetube.com/bti>
> > A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/>
> 
>  small.jpg
> 2KViewDownload




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



Rendering a view for ajax and non ajax

2006-12-03 Thread Grant Davies
Hi guys,
 
I have a view where I need to render the same content when its an ajax
call another time when its first page render.  I don't want a duplicate
of the table_contents.thtml file even if its uses elements to create
itself. So in the table_content.html view file has :
 

$this->render("table_contents");

 
and in the controller when I do an ajax update I do :
 
$this->render('table_contents', 'ajax');
 
the issue is when you render  a view inside a page causes it to render
the view with its layout so it closes the html tag and the body tag at
the end of the render call, and anything after is techinically invalid
since the html tag has been closed. So my initial page render is
actually wrong due to the table_contents being a view file and not an
element file.
 
I know you can use elements for "content" which I do to actually create
the details of the table_contents.thml but when the page loaded the
first time its table_content div is the same as when its called from
ajax and I hate having a duplicate view thml file.
 
Cheers
Grant
 
 
 
 
...
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti <http://www.bluetube.com/bti> 
> A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/> 

 


--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---
<>


ajax issue "stale" data ?

2006-11-30 Thread Grant Davies
I have a weird issue going on.
 
we have a "filter" that returns results based on a list box, this works
great and I've run it in the debugger to make sure it works.
 
load the page and the page view says "20 results" which is correct
because we have not applied the filter yet. You now select a value in
the list box say "give me stories where the name = "john", an ajax call
is made to the controller, it exectutes the query and then renders the
view called "results_ajax" which updates a div tag "results".  I put
some debug code in results_ajax.thml and it correctly says there was 1
result,  this then calls render element to create a results table ->
results_table.thtml and I put some alert in ther too and it says there
we 20 results, which is what the results where before I applied the
filter.
 
I though it could be caching so I deleted the cache files at each click
but no change, I'm trying to figure out what this is, it appears the
view gets the right data, but the element rendered from the view is
getting the old data... its very odd.
 
Cheers
Grant
 
 
.......
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti <http://www.bluetube.com/bti> 
> A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/> 

 


--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---
<>


RE: Associations without using foreign key?

2006-11-12 Thread Grant Davies

 Luigi,

The join table which is the 'extra' table is a common practice and good
design principle in when working with databases, when you say it seems
like unnecessary work, how will you stop someone inserting a record in
your blog favorites that has no relationship to the blog posts table,
you would it in code, but if you have a join table that has foreign keys
to the two tables you an configure the database to not allow an unknown
key to be inserted, this gives you DATA INTEGRITY which is a key part of
a well developed application.  So your code could attempt to keep things
clean and consistent but your DB will not allow records with unmatched
keys to be inserted.

I'd suggest reading the book "Database Design for Mere Mortals" for a
good idea on well defined schemas.  

Cheers
Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Luigi
Sent: Saturday, November 11, 2006 10:24 PM
To: Cake PHP
Subject: Associations without using foreign key?


Hi all,

Is there anyway to specify a hasMany or belongsTo association that
doesn't use a foreign key? I have two tables:

blog_posts: id, author_id, title, text
blog_favorites: id, user_id, author_id

The idea of blog_favorites is that every user can choose a few favorite
authors, and the blog_posts can be queried based on the match between
author_id's. However, there are no foreign key available for an
association, because in both tables the author_id isn't the primary key.
It seems like I would have to build an association through a separate
author table, but that just seems like unnecessary work.

Thanks.




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Cake PHP Vs Prado Vs Symfony

2006-11-11 Thread Grant Davies

 
I can't really comment on other php frameworks. But I've been developing
software professionally for over 18 years, my "day" job is an Enterprise
Architect and I do a lot of J2EE apps, I've done EJB's, spring, struts,
hibernate, and then on the .NET side Nhibernate amongst another trillion
frameworks.  In flash (actionscript) I've used arp and I wrote arpx,
I've also used cairngorm.

Cake is the best framework I've every used for speed of development, I
wish there was something like it for java (the rails port sails is the
closest thing but still seems immature) and for .net (spring for .net
helps, but its very configuration heavy).

There are some things cake lacks (good programmer error handling for
database issues, transactions etc).  But overall Its ridiculous how
quick you can build an application.

I don't like php's syntax as I was a C/C++ programmer and .net and java
syntax is my personal preference, but due to cake I've actually decided
to build 3 projects in cake over using .net due to the sheer simplicity
and ease of development cake has provided to me over .net and java
frameworks.

Just my 2 cents :)

Cheers
Grant

--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: transactions

2006-11-10 Thread Grant Davies

Wow thanks for looking into this, I had put it on the back burner right
now, I'm going to play with that today, thanks a bunch!

Grant.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Kai Zaunick
Sent: Friday, November 10, 2006 1:22 AM
To: Cake PHP
Subject: Re: transactions


Hi Grant,
was just digging into the mysql transaction problem...
It seems if you are using PHP5, you can directly use model->begin,
commit and rollback. Every unknown method of your model is directly
dispatched as a database query (cake uses the __call function to
"catch" unknown methods).
The more correct way is certainly to use the internal structures which
need to be patched...

Cake is a nice framework, but transactions should have a high priority
on the feature list as they are necessary for complex applications.


Grant Davies wrote:
> I've done some searching and found transactions comes up sometimes but
> there doesn't appear to be a definite answer.
>
> I found this :
>
> https://trac.cakephp.org/ticket/832
>
> And I see that the dbo_mssql.php file has some transaction support in
> it.
>
> Has anyone tried the patched model with mysql to use transactions ?  I
> have an application that I need transactions for and right now I'm
> having to delete an inserted row if a insert to another table fails.
> 
> Thanks
> Grant




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Controller calling an other controller?

2006-11-08 Thread Grant Davies

Thankyou, for some reason I'd interpreted the request action as a way to
access another view and not just the action of a controller, thanks for
the clarification.

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jon Bennett
Sent: Wednesday, November 08, 2006 11:13 AM
To: cake-php@googlegroups.com
Subject: Re: Controller calling an other controller?


> Does someone have an example of 1 controller calling another?

you'll be wanting 'requestAction' sir.

Bascially, you call the full url from a controller or view, and the
calls the method and returns the result, eg:

// tests_controller
function getData ()
{
return $this->Test->findAll ();
}

// examples controller

function index ()
{
$tests = $this->requestAction ('/tests/getData');
}

more info on http://manual.cakephp.org/chapter/controllers

hth

jon

-- 


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett



--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Web services, xmlrpc, help!

2006-11-06 Thread Grant Davies

I'd like to see it too, we have to implement a REST based service but
may be able to borrow some concepts.

Grnat.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Monday, November 06, 2006 3:14 PM
To: Cake PHP
Subject: Re: Web services, xmlrpc, help!


Synchro,
I have just "finished" a woking implementation of SOAP on cake. It's
not RPC, but it's a place to start. I wrote a case study for the
Bakery, I'm still wating on a moderator to approve/reject the article.

If you're in a hurry, I could email the article to 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?hl=en
-~--~~~~--~~--~--~---



transactions

2006-11-04 Thread Grant Davies

I've done some searching and found transactions comes up sometimes but
there doesn't appear to be a definite answer.

I found this :

https://trac.cakephp.org/ticket/832

And I see that the dbo_mssql.php file has some transaction support in
it.

Has anyone tried the patched model with mysql to use transactions ?  I
have an application that I need transactions for and right now I'm
having to delete an inserted row if a insert to another table fails.

Thanks
Grant

--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: more validate options

2006-11-03 Thread Grant Davies

I'm not very good at reading regex so will that string support domestic
numbers only or international too ?

Grant.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of rubo77
Sent: Friday, November 03, 2006 7:05 AM
To: Cake PHP
Subject: more validate options


i added another validate option to the scripts/bake.php  script:
line 421:
$prompt .= "6- VALID_TELEPHONE\n";
line 443:
case '6':

$validate[$field['name']] = 'VALID_TELEPHONE';
break;


and in
app/app_model.php:

define('VALID_TELEPHONE', '/^[\(\+0][\/\(\)0-9 \-]+$/');

if you have more ideas for more validate options post them here




--~--~-~--~~~---~--~~
 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?hl=en
-~--~~~~--~~--~--~---



RE: Saving multiple models from a view and validation

2006-11-01 Thread Grant Davies








Ok, now I have my validation working with a save I have a bit of a
conundrum.

 

It doesn't look like cake fully supports transactions,

 

My Asset hasOne AssetData

 

The asset_data table has a foreign key asset_id back to the asset
table.

 

To insert a complete asset, I need to insert a record in the asset
table and in the asset_data table.

 

The code does this :

 

$this->data['Asset']['archive_state_id']
= 1;

    $this->data['Asset']['asset_uri'] =
"tbd/fakefolder";

    $this->data['Asset']['active'] = 'y';

    

    if ($this->Asset->save($this->data))

    {

    $assetId =
$this->Asset->getLastInsertId();

    

    $this->data['AssetData']['asset_id'] =
$assetId;

    

    

    if
($this->Asset->AssetData->save($this->data))

    {

    $this->flash("saved the
asset", "/assets/add");

    }

    else

    {

    $this->flash("Unknown error
trying to save asset", "/assets/add");  

    

    }

 

The problem is if validation fails on my assetData then I will have
already saved the asset record. The cake docs and some discussion did not
recommened calling invalidates($this->data) from my model since save calls
that before saving, but since there are no real transactions and I can’t
rollback, should I just throw caution to the wind and directly call invalidates
before saving the asset model so that if validation fails I’ll know
before I’ve created an asset record ?

 

Thanks

Grant




--~--~-~--~~~---~--~~
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 multiple models from a view and validation

2006-11-01 Thread Grant Davies

I got validation to work by changing this :

$this->validateErrors($this->AssetData);

to

$this->validateErrors($this->Asset->AssetData);

Can someone tell me why the former doesn't work ?

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of realien
Sent: Wednesday, November 01, 2006 10:31 AM
To: Cake PHP
Subject: Saving multiple models from a view and validation


I've been looking at this for a few hours now and searched a lot of
posts, so I'm throwing my hands in the air and asking for help :)

I have an add method on my controller :

 function add()
   {

if (empty($this->data) )
{

$this->render('add');
}
else
{


$this->data['Asset']['archive_state_id'] = 1;
$this->data['Asset']['asset_uri'] =
"tbd/fakefolder";
$this->data['Asset']['active'] = 'y';

if ($this->Asset->save($this->data))
{
$assetId = $this->Asset->getLastInsertId();

$this->data['AssetData']['asset_id'] =
$assetId;


if ($this->Asset->AssetData->save($this->data))
{
$this->flash("saved the asset",
"/assets/add");
}
else
{

$this->set('data', $this->params['data']);
$this->validateErrors($this->AssetData);
$this->render('add');
}
}
}
}


my add view has the appropriate html tag tagErrorMsg



Slug :
input('AssetData/slug', array('size' =>
'50'))?>
tagErrorMsg('AssetData/slug', 'Slug is
required.') ?>


Other Info:
textarea('AssetData/other_info',
array('rows'=>'10')) ?>


submit('Save') ?>



my asset data model has the validate array :

var $validate = array(

'slug'  => VALID_NOT_EMPTY


);

and my AssetController has the correct uses :

   var $uses = array('Asset', 'AssetData');


What happens right now is it correctly saves the asset and then save on
the AssetData model returns false since the validation fails (I see it
by single stepping the code) but my html tag error messages never get
displayed...

Please someone help me from this frustration :)

Thanks
Grant




--~--~-~--~~~---~--~~
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: Application Architecture

2006-10-26 Thread Grant Davies

Thanks Grant, that does make a lot of sense, I do display a form, the
xml usually has incomplete data that the user needs to update in the
form, so the xml is there just to "seed" the form.  I guess I can read
an example record from the database and then dump the associative array
to a file so I can see how to make sure I populate and empty one
correctly?  What I was looking for is "best practice", i.e. do people
just look at their database and start typing into their associative
array or is there some best practice for making sure you get all your
fields correct such as dumping a record you have read from the database
?

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Grant Cox
Sent: Thursday, October 26, 2006 7:27 AM
To: Cake PHP
Subject: Re: Application Architecture


I'm not sure what you mean by "baking" the model - bake is just a
command line application to make model/view/controller stubs (although
stubs doesn't give them much justice, they are very functional).  Even
a "complete" model file will not specify the database fields, except
where needed for validation.

But anyway.  So you have your XML uploaded (and related Quicktime
files), you've parsed the XML data, and now you want to save it.
Firstly, do you really need the form before saving?  If it is just for
manual validation before the data is saved to the database, is this
really needed unless there is an error?

I would suggest that your parsing converts the XML into associative
arrays suitable for saving as model data.  Yes, this does mean that you
need to know the database field names in your parsing/conversion code,
but this isn't really that bad (you need to know the XML field/element
names too).  Rapid development is the key here, rather than over
architecting parts that aren't really likely to change.  Once you've
parsed the XML into an associative array of model data, just save it
and rely on the Model's standard validation.  If this save fails,
display an edit form just like any other edit() action, for manual
verification.

Of course, this is assuming your XML inserts only a single model row.
If it has a number of rows, then it would probably be best to parse and
validate the data, and display some kind of summary validation page to
the user.  If they continue, the file is again parsed, but the models
are saved.  This is the approach I'm using for uploading a CSV of user
data, where if there are problems it is easier for the user to
re-upload the file than to use a form to fix each row.




--~--~-~--~~~---~--~~
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: Application Architecture

2006-10-25 Thread Grant Davies

 Wow, I'm loving cakePHP and have made a ton of progress.

What I'm trying to figure out now is the best approach for the
xml/view/save.

I have my xml loading and figured out and my form, I'm thinking :

A) do I use the bake utility to create a concrete version of my model
(assume to has all the data members from my table) and then :

1) read the xml
2) use the concrete version of my model and pass it to the view via the
controller
3) view uses an instance of the model to pre-populate the form
4) upon submit use the standard cake validation etc and write the model
to my database.

Or do I

B) Use the associative array version of my model and populate it with
xml :

1) read the xml
2) use the associate array version of the model and hope I spell all the
column names correctly

Steps 3 & 4 are same as above.


I'm a little nervous about trying to populate the "dynamic" model that
will be initial empty, maybe its because I come from a java background.
Is baking the model the preferred approach ?

Thoughts on this approach ?

Cheers,
Grant

--~--~-~--~~~---~--~~
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: THTML files not working

2006-10-25 Thread Grant Davies

I'm a noob and have a suggestion, get the eval copy of Nusphere's php ed
, hit a page then step through the code in the debugger, I didn't really
understand the controller/view mapping until today, when I stepped
through the code and figured out how cake looks for your request, maps
it to a controller then figures out your action, and what an action
is...

Its helped me a bunch.

Grant. 

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Chris Hartjes
Sent: Wednesday, October 25, 2006 11:54 AM
To: cake-php@googlegroups.com
Subject: Re: THTML files not working


On 10/25/06, barry_normal <[EMAIL PROTECTED]> wrote:
>
> Hi guys.
>
> Well, php is running fine. I get the welcome screen from Cake okay.
>
> Here's the url: http://192.168.0.2/app/views/posts/index

Well, here's part of your problem.

The URL should be http://192.168.0.2/app/posts/index

Again, I stress, you NEVER access the views directly.

It's always host/controller/action/optional-id

In this case, 'host' is http://192.168.0.2/app

Hope that helps.

/me goes back to being cranky about writing XML parsers for XML feeds
that won't follow their own documentation on what content is presented

--
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: Application Architecture

2006-10-25 Thread Grant Davies

 Thanks grant.

What I've done so far is created a controller to parse the xml, it uses
xpath to get the nodes/attributes that I need (I don't need the whole of
the xml).

No what I want to do is populate an instance of a model "asset" with the
contents of the nodes I captured, I see that the model is an associative
array so do I have to manually populate an associate array to be a copy
of my db table.

Any links to anything that does this ?  Basically it would be like
having a from on screen, filling it in and then creating a new record I
guess , just in my case the xml is used to pre-populate the form.

 (I have a java applet that ftp's some QuickTime files to the server
with an xml file and my cake/php app parses the xml and pre-populates a
form).

My concern here is I use cake where I can instead of just coding it
myself and slotting it into cake and not using cake's "abilities".

Cheers,
Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Grant Cox
Sent: Wednesday, October 25, 2006 6:00 PM
To: Cake PHP
Subject: Re: Application Architecture


That (1) is pretty much exactly what I would do.  Make a component that
parses your XML into an associative array.  Get your controller action
to pass the uploaded XML to this component, then use the array data to
create and save instances of your model(s).

I agree a lot of heavy lifting can be done in a model, but I wouldn't
put XML parsing in there as it is a generic action.


On Oct 26, 3:37 am, "realien" <[EMAIL PROTECTED]> wrote:
> 1) I parse an XML file from a dv camera and need to insert what I get 
> into my database, I will have models for the data, but do I create my 
> xml parse class in my own "package" and have my controller call it  
> and map it to my model somehow before inserting it into my database?  
> Not quite sure where it should fit.




--~--~-~--~~~---~--~~
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: new to cake, and mvc in general

2006-10-23 Thread Grant Davies

I would be very interested in responses to this, especially the
validation areas so please keep the discussion on-list if possible.

Thanks
Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Monday, October 23, 2006 12:28 PM
To: Cake PHP
Subject: new to cake, and mvc in general


Greetings,

After putting work in for the past few months on a system I was going
to build on phpBB3 (when it was released) I've decided to move over to
a framework. Most of the work I've done is portable, as I was building
around phpBB3, instead of modding it, with it being in development
still.

I did a lot of research, and it came down to 3 frameworks to try.
Django, Code Igniter, and Cake.

I went with Cake first. I didn't want to learn python, as it would
basically invalidate most of the code I wrote already. Between Cake and
Code Igniter, Cake appears to be the more robust of the two.

I've had no problems with installation, even with using Xampp on my
windows xp box for development.

However here's some things I'm looking at, that I haven't found
immediate answers for in the documentation.

Data Validation - It's way too simple for what I want. I'm looking for
ways to say, validate a date field is a real date, and then also
validate that it's in an acceptable range (ie: over 14 years old). I'd
also like to be able to set custom error messages based on error.

Now, it looks like i can do a lot of this if i move more validation
into the controller. I can then feed error messages using
this->set('errorMsg', 'whatever'); and then display errorMsg in my
view's return for an invalidate. However, as I understand it, i should
be doing validation at the model level?

I did try some of the snippets out there for overriding invalidate in
app_model.php. I mainly just encountered preg-match errors all over the
place and they didn't work.

Database Access - Right now I'm just building a simple registration
form for users. I noticed with sql debugging turned on that on the
initial page view, before any of the data is submitted, a sql query is
made to describe the table (DESC `users`). It appears that every page
view using the model/controller/view setup does this query? This looks
to me like unnecessary sql queries. Is there a way to set it so it only
queries when it actually needs to interact with the database?

Views - The tutorials I've found have dealt with pages that interact
with the database for one thing. Like a blog. However, some of my pages
are going to need to interact with different tables to display all
types of information. My index page for example would show site
announcements, new members, advertisements, maybe even latest forums
posts, etc etc. Users will have a home page that once again would be a
consolidation of various queries of unrelated information. Are there
any tutorials for accomplishing this kind of thing?

As I said, I'm entirely new to the MVC way of thinking.

So far though, I'm generally impressed and believe I should definetly
be able to speed up the process of development with Cake, now that I'm
getting my head wrapped around 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: Got the cake blog running but got a "cache" issue ?

2006-10-22 Thread Grant Davies

 On my windows box right now, will also be testing on my mac :)  I have
to figure out what user apache runs under windows, but for now I made it
writable and it seems to be behaving :)

Thanks for the tip.

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of VaultedCeilings
Sent: Sunday, October 22, 2006 11:01 PM
To: Cake PHP
Subject: Re: Got the cake blog running but got a "cache" issue ?


It's a permissions problem, open up some terminal application and change
the owner of the tmp (and recurse through sub directories) to whatever
the server is.  In my case (on mac os x) I did the following...

sudo chown -R www:www /path/to/tmp/dir

That should take care of it, if you plan on editing files in that
directory you might consider making the group yourself instead of www.




--~--~-~--~~~---~--~~
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: Got the cake blog running but got a "cache" issue ?

2006-10-22 Thread Grant Davies

 oops, sorry for the hijack and thanks for the link.

Grant.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of nate
Sent: Sunday, October 22, 2006 10:59 PM
To: Cake PHP
Subject: Re: Got the cake blog running but got a "cache" issue ?


Hi Grant, try this search instead:
http://groups.google.com/group/cake-php/search?group=cake-php&q=tmp+writ
eable&qt_g=1&searchnow=Search+this+group

Also, please open a new topic when you want to ask a question, rather
than hijacking someone else's thread (I'm sure it was inadvertant, this
is just FYI).




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Got the cake blog running but got a "cache" issue ?

2006-10-22 Thread Grant Davies



Hi guys, I did a search but didn't find a match for this 
issue,
 
I have cake running and the blog tutorial put together part 
way and it works but I get warnings at the top of my pages :
 
Warning: 
file_put_contents(C:\Program Files\Apache Software 
Foundation\Apache2.2\htdocs\app\tmp\cache\models\default_caketest_list) [function.file-put-contents]: 
failed to open stream: No such file or directory in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\cake\basics.php on line 
835Warning: file_put_contents(C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\app\tmp\cache\models\default_posts) [function.file-put-contents]: 
failed to open stream: No such file or directory in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\cake\basics.php on line 
835
 
I created the folders 
incase I was supposed to :)  But is it a permissioning issue where cake 
can't write a cache file ? or something else ?
 
cheers,
Grant
 
 
. › b l u e t u b e p r o d u c t i o n s .: Grant Davies  
{ c.t.o } .: 
404.428.6839 (office) 
.: 
708.983.1577 (fax) 
› [EMAIL PROTECTED] 
› http://www.bluetube.com › http://theresidentalien.typepad.com 
 


From: cake-php@googlegroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Sonic 
BakerSent: Sunday, October 22, 2006 8:22 PMTo: 
cake-php@googlegroups.comSubject: Re: Using Simpletest and the Cake 
testing framework... with models
Hi there,See if the following helps:

// 
  testing insertfunction test1(){   $data = "" // 
  stuff here );   
  $this->assertTrue($this->user->save($data));}// testing fail 
  to insert duplicate datafunction test2(){   $data = 
  "" // same stuff here );
$this->User->cacheQueries = false; 
   
  $this->assertFalse($this->user->save($data));
$this->User->cacheQueries = true; 
}I'm 
not sure if it needs to be set back to true afterwards so I put it there just to 
be safe. You could also probably put these in the setup() and teardown() 
methods but again I'm not certain how this will affect the rest of the 
app.I asked these questions before but didn't get any responses. Perhaps 
someone can shed some light on the subject? http://groups.google.com/group/cake-php/browse_thread/thread/f63c6883a8d301ff/211449bb08d706fe?lnk=gst&q=cacheQueries&rnum=1#211449bb08d706fe 
HTHCheers,Sonic
--~--~-~--~~~---~--~~
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: First time installation - need help

2006-10-22 Thread Grant Davies

 
Thanks, turned out to be I needed an empty controllers folder under the
cake install and all the warnings went away, I'm now configuring mysql
and have added the php folder to the windows system path and enabled the
php_mysql.dll in the php.ini file, but its still giving me no love, I'm
going to try rebooting incase the env is not being read by apache
properly..

Grant

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of BlenderStyle
Sent: Sunday, October 22, 2006 2:10 PM
To: Cake PHP
Subject: Re: First time installation - need help


First off, do you have PHP working with Apache? Create a file in htdocs
called test.php with the lines below. Then browse to
http://localhost/test.php and see if it works. I'm not sure what you
mean by, "the problem is the index.php file where i need to set."






--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---