Re: Strange session problems ;-(

2006-07-03 Thread Christian.Tietze

Well, it's not obvious what really changes things here... You could try
to pr($data); if there's something wrong inside your result (but you
should've noticed that in your view, hmm :))... Probably Session::write
returns true or false, depending on the sucess of writing. You could
try:

if ($this->Session->write(...)) {
  echo 'Works fine. ID: ' . $id;
}

Debunng 3 lines of code isn't easy :)


--~--~-~--~~~---~--~~
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: custom foreignKey not working in depper associations

2006-06-25 Thread Christian.Tietze

Has been fixed yesterday, phew :)


--~--~-~--~~~---~--~~
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: HABTM recursively

2006-06-24 Thread Christian.Tietze

I found out that recursion seems to work well. There is a query in
debug mode 2, but the values are wrong; more precisely, the
Comment.author_id is tested with NULL.

Querying for a user only results in all his comments included in the
result as supposed.
Querying for a news item, which queryies for an 'Author', which
therefore queries for comments, that doesn't work. Same with
news->comments->author.
I think that's because the news refer to users as 'Author' (alias in
the query as well) but the author's comments may expect 'User' in some
way, I don't know how cake handles this and I'm not able to find out by
browsing the code :S

Described the whole thing there:
http://groups.google.com/group/cake-php/browse_thread/thread/25035ff3c0a24550/efda7db325b09378


But thanks for your help. Didn't know about the last parameter in
find() :)


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



custom foreignKey not working in depper associations

2006-06-24 Thread Christian.Tietze

Hi!

Please excuse this rather long post; my English isn't that advanced and
therefore it's ahrd to explain things the short way. Maybe I'm going to
say the same thing twice, using another expression or so, hoping you
can get the meaning out of them combined :)

To describe my problem: If I show a news item, the comments are
associated (i show them as well) and for each comment there's a user.
The news and the comments refer to the user via
   'foreignKey' => 'author_id'
because that makes more sense than user_id would do while reading and
writing the templates.

That's no big deal, though. I created a static page, so only the
sidebar contains a query to fetch the logged-in user's details.
I associated news and comments to the user via User::hasMany, changing
the foreignKey value to 'author_id' as well (as proposed in the manual
on hasMany: http://manual.cakephp.org/chapter/6).
For the sidebar there is a query for the user's data which leads to a
query for his news and comments. Using debug mode on level 2, I see the
query, and there are 3 news and 1 comment fetched. That's what there is
in my DB, so everything is fine.


Yeah, now there's a problem though.

Then I show a single news post, written by me. One of the 3 the DB
found for my user data above.
The news post is fetched and the author (refered to as 'Author' in my
relationship, so its "SELECT `Author`.`id` FROM `user` as `Author`"
instead of `User`!) can be found as well.
Remember what I told you about querying the DB for a user? Because of a
high 'recursive' value, the author's contents (news and comments)
should be fetched as well. And there's the problem (see the queries far
below).
The news item is there, then the news' author is there, but the news'
authors' comments don't show up, because the author_id is tested on
NULL isntead of an integer value. I suppose the WHERE-clause is made
like this:
' WHERE `Comments`.`author_id` = ' . $someArray['User']['id']
wheras it should be 'Author' as well (because the news refered to the
user this way).

Sounds like some kind of bug to me. The tables' alias is changed in one
query, but all querys afterwards expect the default alias (`User`).
It's hard to express what I think because I lack a lot of English
vocabulary... The supposedly used array index 'User' is derived from
the model's name (class User extends AppModel), a class/model called
Author is not available but supplied by the news. I hope you can get a
glimpse of what I try to say...


Is there a way to fix this? Using "User" instead of "Author" for
describing the relationship isn't a good solution since the code will
lack readability then :(

Well, thanks in advance for any suggestions!


- Christian


The SQL queries (hopefully you all got fixed fonts :))

 Fetching the news
SELECT `News`.`id`, [...] ,`News`.`author_id`,
   `Author`.`id`, [...] ,`Author`.`email`
  FROM `news` AS `News`
  LEFT JOIN `users` AS `Author` ON `News`.`author_id` = `Author`.`id`
 WHERE (`News`.`id` = 6)
 LIMIT 1

 Fetching the news' author (id=2 is me)
SELECT `Author`.`id`, [...], `Author`.`email`
  FROM `users` AS `Author`
 WHERE `Author`.`id` = '2'

 Fetching the news' author's comments
SELECT `Comments`.`id`, [...] `Comments`.`author_id`
  FROM `comments` AS `Comments` 
 WHERE `Comments`.`author_id` = NULL


--~--~-~--~~~---~--~~
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 tutorial for newbies

2006-06-23 Thread Christian.Tietze

Good work - but why do you offer a PDF?
Copying source out of a PDF is just bloody ugly. We're forced to accept
the PDF's line wraps because of the limited page width... A good
looking HTML page (probably you could use wordpress' static pages for
that with some (cached?) syntax highlighting) will serve a coders needs
much better, I think.
I personally prefer HTML because of the accessibility - I can scroll
_fast_ and use the page like any other website or text document.

So please publish your tutorial in HTML and continue up your writing :)


--~--~-~--~~~---~--~~
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: HABTM recursively

2006-06-23 Thread Christian.Tietze

Don't ask me why, but now (maybe I changed that this morning and forgot
until now) there's a hasMany relationship from News to Comments.
The HABTM relationship is between News and Tags. I could have mixed
that up because of the early hour :)

Nevertheless, the problem is the same.

Some code snippets:

class News extends AppModel {
var $hasMany = array(
'Comments' => array(
'className' => 'NewsComment',
'order' => 'created DESC',
'dependent' => true
)
);
}

class NewsComment extends AppModel {
var $belongsTo = array(
'News' => array(
'className' => 'News'
),
'Author' => array(
'className' => 'User',
'foreignKey' => 'author_id'
)
);
}


What I'm doing now as some kind of workaround, but shortened:

class News extends AppModel {
function show($id) {
// Fetch the item
$news = $this->News->findById($id);

$tempComments = array();

/*
 * Fill in the comments with more detailed information
 */
foreach ($news['Comments'] as $comment) {
// Get full comment details
$comment = $this->NewsComment->findById($comment['id']);

// ...

$tempComments[] = $comment;
}

// Overwrite the old comment array
$news['Comments'] = $tempComments;

$this->set('news_item', $news);
}
}

You see, I'm fetching the entire comment in the foreach loop to get the
author's data. The array (using pr()) is finally rendered as desired
(see first post).
Now, each (numeric) comment entry in $news['Comments'] includes
[NewsComment], [Author] and [News] - the news item itself. It's waste
of bandwith, but I don't know what to do else to have [NewsComment] and
[Author].

I _could_ live without [Author] (the default case, described in 1st
post) because I'm able to fetch the user manually by ID. There are keys
titled 'author_name', 'author_email' and 'author_website' in the
comment's very own data and I fill in these fields manually for
registered users because they're only necessary if a guest is writing.
This way I can access $comment['author_website'] in the View, no matter
if the author was a guest or not.

Writing all this makes me think... :)
I changed a lot since this morning, so there's no necessity of having
the registered author's full profile anymore.
But I may run into the same problem with other models.
The point is that I don't understand _why_ there's no [Author] data by
default. It should be there - everything else is as well...


--~--~-~--~~~---~--~~
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: ->What is the diffrent between $html->hidden and $html->hiddentag ?

2006-06-22 Thread Christian.Tietze

It's just there because of backwards compatibility.

Taking a look at the source (it's always good to have an IDE which
shows a list of every included code available) would tell you the
following

/**
 * @deprecated Name changed to 'hidden'. Version 0.9.2.
 * @see HtmlHelper::hidden()
 * @param string  $fieldName If field is to be used for CRUD, this
should be modelName/fieldName.
 * @param string  $value
 * @param array $htmlAttributes Array of HTML attributes.
 * @param boolean $return Wheter this method should return a value or
output it. This overrides AUTO_OUTPUT.
 * @return mixed Either string or boolean value, depends on AUTO_OUTPUT
and $return.
 */


All the *Tag methods are more or less deprecated; but e.g. there's no
alternative for formTag(), you're supposed to write the  thing
manually, using the HtmlHelper::url() method (recommendation is in the
source as well :)).


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



HABTM recursively

2006-06-22 Thread Christian.Tietze

Hi!

It's nagging me that hasAndBelongsToMany-relations do not respond to
$recursive.
I've got a news script. One can comment on the news, the news are
fetched correctly and the comments (a HABTM-relationship from
news->comments and a belongsTo-relationship from comments->user) are in
a numeric array. nothing wrong so far.
But when it comes to rendering the comment's details, I've got to
access the details of the author, e.g. to print his name (it's stored
in the database for the comment, just in case a user might cancel his
account, so that the name's left - or for guest postings). But the
'Author' relation isn't available directly.
I changed News->recursive from 1 to 2 ('Author' appears for comments,
but without value) and then to 5 to check whether it's an issue of
depth, but the Author-field is always empty.

I didn't plan to have a comment controller (since
'/newsComments/write/NEWS_ID' doesn't look as good as
'/news/comment/NEWS_ID') but now I just created one to have a method
called 'getComment($id)' which I can call from the view with
requestAction()  to fetch full details for every comment. There, all
relations are filled in just fine.

Now I wonder why HABTM-data is stored directly in a numeric array;
isn't is possible to have something like

...
[NewsComments] => Array
(
[0] => Array
(
 [NewsComment] => Array
 (
 )
 [Author] => Array
 ( 
 )
)
)
...


instead of

...
[NewsComments] => Array
(
[0] => Array
(
 [id] => 3
 [title] => asd
 ...
 [author_id] => 2
 [news_id] => 13
)
)
...


a foreach-loop to iterate every comment is currently breaking the habit
of writing $array['ModelName']['attribute'], because it's more
$item['attribute'].
Can I change that? Somehow? Or am I supposed to fetch the comment's
details by myself (requestAction() call etc.)?

Some things in CAKE still seem strange to me :)
Well, thanks for your help in advance!

Greetings,
Christian Tietze


--~--~-~--~~~---~--~~
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: Selling CakePHP apps - license changes?

2006-06-21 Thread Christian.Tietze

If the customer wants yet another website, we will charge him for the
design and for every man-hour of modifying the code. I don't think that
we want to sell a licensed product to them (that always reminds me of
game engines which are licensed one time for every game), maybe I just
haven't found out yet what all this licensing means... I know the GPL
and, at least now, the MIT license which both protect a user's right
for open source software. I never looked for anything else yet and so I
just imagined that non-open source licenses might protect the creators
property and by no means restricts the sale.

Hmm, well, it's kind of difficult for me to express such specific
things in English :)

But thanks for your advice. I think I exaggerated a bit with all this
licensing; maybe I'm getting paranoid if it's about my work :)


--~--~-~--~~~---~--~~
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: Selling CakePHP apps - license changes?

2006-06-21 Thread Christian.Tietze

Thanks for your two answers!
Yeah, I copied the app_controller and app_model files into my /app
directory and right now I'm happily changing the class description :)
What I still lack is a new licence. Do I need one? Or is "Copyright (c)
2006 Christian Tietze & Daniel van Westen" enough? Since we're
freelancers, a lawyer is way outside of our budget.


Olivier Percebois-Garve wrote:
> Better sell expertise, set up, adaptation, customization of code, rather
> than code itself.

Your first point sounds as if we're selling the code for code's sake :)
We develop a management system for small groups, so the content is
somewhat limited, it's a really basic solution. I'm programming the
backend in Cake and my colleague designs our customer's pages. It's my
turn to adjust some things in our product's backend then, so we're
offering a whole website - not just the code, just in case my first
description misleaded you this way.


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



Selling CakePHP apps - license changes?

2006-06-21 Thread Christian.Tietze

Hi there!

I looked at the MIT license just a few minutes ago:
http://www.opensource.org/licenses/mit-license.php

You can see this license's URL in every class of CakePHP including
AppController which one has to modify for global changes etc. - you
know all that.
But I wonder whether my application's rights are limited due to this
license... The client receives all the code, the models and the views
and the controllers and he's paying, we're selling, we want money for
our work - so we don't want any of our clients to copy or resell parts
of the code. Deleting any documentation and making the code a pain to
read may be ONE solution, but I don't think that this is a good idea.
The MIT licence, if I really understood what is written there, says
that everyone receiving a copy of the code is permitted to
redistribute, sell and copy it.
That's nice for the framework, but we don't want people to do so.

What do you suggest?
Shall we link to another licence from our own classes?
Shall we think about open source _and_ selling? :) I'm going to publish
useful parts or another "version" of the software anyway...

Thanks for your advices in advance!

Greetings,
Christian.Tietze


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