Re: Taking advantage of Cake to build personal book database

2007-11-11 Thread maschoen

btw,

When a book is reissued, it gets a new ISBN.  I think just the
last digit changes.


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



Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Baz
*Sigh*,

So I've been pulling out my hair for a while until I figured, this thing
just doesn't work the way it should.

Here's my scenario very simplified with test data:

Controller1:

$arr['name']['1'] = '21';
$arr['name']['2'] = '21';
$arr['name1']['1'] = '21';
$this-Cookie-write('zilla', $arr, false);
$this-log('What\'s my cooking');
$this-log($this-Cookie-read('zilla'));

Output:

(
[name] = Array
(
[1] = 21
[2] = 21
)

[name1] = Array
(
[1] = 21
)

)

Controller 2:

$this-log('What\'s my cooking');
$this-log($this-Cookie-read('zilla'));

Output:
(
[name] = Array
[name1] = Array
)

It basically eats up the second dimension on an array.
Any ideas?

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



String concatenation not working

2007-11-11 Thread technicaltitch

Hi

I'm developing a hands-off website CMS in CakePHP, and I want it to
email me a dump of the database every 6 months as a backup. I have
bodged the model_php5.php and dbo_source.php so they return the insert
statement of a model as a string, based on the save and create
functions but not running the sql. However I can't concatenate the
output.

The code:

function backup() {
$sql_string = array();
$sql_string2 = '';
$sql_string3 = '';
$i = 1;
$articles = $this-Article-findAll();
foreach ($articles as $article) {
$sql_string[$i] = $this-Article-saveString($article);
$sql_string2 .= $this-Article-saveString($article);
$i = $i + 1;
}
$sql_string3 = implode(;,$sql_string);
$this-Session-setFlash('$sql_string'.$sql_string[1].'-'.
$sql_string2.'-'.$sql_string3);
$this-redirect('/articles/index');
}

The array is fully populated, however as soon as I try to concatenate
the strings in the array, it becomes undisplayable - no error is
displayed but no string is displayed either. (In the case above none
of the three strings are displayed, but if I remove $sql_string2 and
3, the array entry is displayed. I've also tried $sql_string2 =
$sql_string2 . $this-Article-saveString($article);

Why won't the concatenate work? I'm completely baffled...

All time and help hugely appreciated thank you.
Chris



The bodge code is - in dbo_source.php - same as 'create' but returning
sql not executing it:

function createString($model, $fields = null, $values = null) {
$fieldInsert = array();
$valueInsert = array();
$id = null;

if ($fields == null) {
unset($fields, $values);
$fields = array_keys($model-data);
$values = array_values($model-data);
}

$count = count($fields);
for ($i = 0; $i  $count; $i++) {
$fieldInsert[] = $this-name($fields[$i]);
if ($fields[$i] == $model-primaryKey) {
$id = $values[$i];
}
}

$count = count($values);
for ($i = 0; $i  $count; $i++) {
$set = $this-value($values[$i], $model-
getColumnType($fields[$i]));

if ($set === '') {
unset ($fieldInsert[$i]);
} else {
$valueInsert[] = $set;
}
}

return 'INSERT INTO ' . $this-fullTableName($model) . ' (' .
join(',', $fieldInsert). ') VALUES (' . join(',', $valueInsert) . ')';
}

And in model_php5.php - the same as 'save' but calling my save db
function:

function saveString($data = null, $validate = true, $fieldList =
array()) {
$db = ConnectionManager::getDataSource($this-useDbConfig);

if ($data) {
if (countdim($data) == 1) {
$this-set(array($this-name = $data));
} else {
$this-set($data);
}
}

$whitelist = !(empty($fieldList) || count($fieldList) == 0);

if ($validate  !$this-validates()) {
return false;
}

if (!$this-beforeSave()) {
return false;
}
$fields = $values = array();

if (count($this-data)  1) {
$weHaveMulti = true;
$joined = false;
} else {
$weHaveMulti = false;
}
$habtm = count($this-hasAndBelongsToMany);

foreach ($this-data as $n = $v) {
if (isset($weHaveMulti)  isset($v[$n])  $habtm  0) {
$joined[] = $v;
} else {
if ($n === $this-name) {
foreach (array('created', 'updated', 
'modified') as $field) {
if (array_key_exists($field, $v)  
(empty($v[$field]) ||
$v[$field] === null)) {
unset($v[$field]);
}
}

foreach ($v as $x = $y) {
if ($this-hasField($x)  ($whitelist 
 in_array($x,
$fieldList) || !$whitelist)) {
$fields[] = $x;
$values[] = $y;
}
}
}
}
}

//set to false so always creates INSERT stmnt - could insert switch
here to create UPDATE strings (and use 'update' below)
$this-id = false;

return $db-createString($this, $fields, $values);
}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to 

Re: Installing cake on top of another cake application

2007-11-11 Thread Marcin Domanski aka kabturek

Hey
 Cake newbie here so I would very much appreciate it if you could help
 me out with my problem. just got a few questions. I'm running cake on
 a shared hosting site and I was just wondering if I can host another
 cake application on top of a working cake app.

Do you have the possibility to change the DocumentRoot ?

you can try settings the subdomain apps as plugins maybe ?

Another thing to try as for the .htaccess -
Add
RewriteBase dir
after
RewriteEngine  on

HTH,
kabturek


--~--~-~--~~~---~--~~
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: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Ivolution

*Probably* the following will work:

before writing your array to the cookie:
$arr = serialize($arr);

after reading it from your cookie (when $cookval is the value you read
from your cookie):
$arr = @unserialize($cookval);

This way you should have your whole array back.

Note however that I didn't test this code at all, it's just the first
thing that jumps into my mind.

Ivo


On Nov 11, 12:45 pm, Baz [EMAIL PROTECTED] wrote:
 *Sigh*,

 So I've been pulling out my hair for a while until I figured, this thing
 just doesn't work the way it should.

 Here's my scenario very simplified with test data:

 Controller1:

 $arr['name']['1'] = '21';
 $arr['name']['2'] = '21';
 $arr['name1']['1'] = '21';
 $this-Cookie-write('zilla', $arr, false);
 $this-log('What\'s my cooking');
 $this-log($this-Cookie-read('zilla'));

 Output:

 (
 [name] = Array
 (
 [1] = 21
 [2] = 21
 )

 [name1] = Array
 (
 [1] = 21
 )

 )

 Controller 2:

 $this-log('What\'s my cooking');
 $this-log($this-Cookie-read('zilla'));

 Output:
 (
 [name] = Array
 [name1] = Array
 )

 It basically eats up the second dimension on an array.
 Any ideas?


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



Disabling cake on a subdomain for Joomla

2007-11-11 Thread chogi

Hey all,

Got a quick question. I got cake running on my root folder of my
shared host. I made a subdomain and i want to run joomla on it. But
when I try to access the subdomain address, it shows missing
controller

Is there anyway to bypass cake or htaccess so that it doesnt look for
the controller when I try to access the subdomain?

Thanks,
Chogi


--~--~-~--~~~---~--~~
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: Installing cake on top of another cake application

2007-11-11 Thread chogi

Got it to work thanks, i just added the subdomain name infront of
index.php on my htaccess file

On Nov 11, 9:31 pm, Marcin Domanski aka kabturek [EMAIL PROTECTED]
wrote:
 Hey

  Cake newbie here so I would very much appreciate it if you could help
  me out with my problem. just got a few questions. I'm running cake on
  a shared hosting site and I was just wondering if I can host another
  cake application on top of a working cake app.

 Do you have the possibility to change the DocumentRoot ?

 you can try settings the subdomain apps as plugins maybe ?

 Another thing to try as for the .htaccess -
 Add
 RewriteBase dir
 after
 RewriteEngine  on

 HTH,
 kabturek


--~--~-~--~~~---~--~~
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: String concatenation not working

2007-11-11 Thread AD7six



On Nov 11, 1:33 pm, technicaltitch [EMAIL PROTECTED] wrote:
snip

Why would you not use mysqldump and a cron job?

AD


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



Sorting related object according to their related objects

2007-11-11 Thread Alex

Hi folks,

I have a model like the following:

Article hasMany Comment
Comment hasOne User

Now I want to fetch all comments from one article limited by ten.
These ten should be the comments with the most popular users
(User.popular). Is it possible to define the Article hasMany Comment
relationship with a limit and an order by his sub-object
User.popular?

Bye,
ALex


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



unbind a behavior / ActsAs

2007-11-11 Thread Zoltan

I'm doing a save on a model inside a controller to update one field,
however it is triggering a behavior attached to that model. Is there a
way to temporarily (like unbind) disable this ActAs so it isn't
called.

Zoltan
www.yyztech.ca


--~--~-~--~~~---~--~~
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: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Baz
Thanks for the response, but here's a few FYIs.


   - What I posted before works fine with Sessions. That's actually how I
   determined the problem. I was building a remember me for a login. And I
   thought I could just dump the session variable in a cookie and retrieve
   later. So maybe if anyone decides to fix this, they might look at the
   Session::write and Session::read.
   - I don't know much about cookies, but it appears that after the
   cookie is saved AND the pages has loaded, we have problems.
   - Now here's the kicker. Your solutions seems fine. And it might be,
   but I've noticed that it doesn't work when the cookie is NOT encrypted. I
   was storing non-encrypted while debug so I could look at values, but when I
   switched to encrypted, it worked like a charm. Go figure.
   - Another FYI, it failed when I tried to store: $this. The initial
   write and read worked, but from the second controller, it failed to read.
   I'm guessing max cookie or something?

Maybe I'm trying to do too much. But regular, small, single dimensional
arrays work fine. And the serialize options works for small multi
dimensional arrays.

ThanX again.

On Nov 11, 2007 9:20 AM, Ivolution [EMAIL PROTECTED] wrote:


 *Probably* the following will work:

 before writing your array to the cookie:
 $arr = serialize($arr);

 after reading it from your cookie (when $cookval is the value you read
 from your cookie):
 $arr = @unserialize($cookval);

 This way you should have your whole array back.

 Note however that I didn't test this code at all, it's just the first
 thing that jumps into my mind.

 Ivo


 On Nov 11, 12:45 pm, Baz [EMAIL PROTECTED] wrote:
  *Sigh*,
 
  So I've been pulling out my hair for a while until I figured, this thing
  just doesn't work the way it should.
 
  Here's my scenario very simplified with test data:
 
  Controller1:
 
  $arr['name']['1'] = '21';
  $arr['name']['2'] = '21';
  $arr['name1']['1'] = '21';
  $this-Cookie-write('zilla', $arr, false);
  $this-log('What\'s my cooking');
  $this-log($this-Cookie-read('zilla'));
 
  Output:
 
  (
  [name] = Array
  (
  [1] = 21
  [2] = 21
  )
 
  [name1] = Array
  (
  [1] = 21
  )
 
  )
 
  Controller 2:
 
  $this-log('What\'s my cooking');
  $this-log($this-Cookie-read('zilla'));
 
  Output:
  (
  [name] = Array
  [name1] = Array
  )
 
  It basically eats up the second dimension on an array.
  Any ideas?


 


--~--~-~--~~~---~--~~
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: String concatenation not working

2007-11-11 Thread technicaltitch

because it's for a bolivian volunteer organization we're using
incredibly cheap hosting which doesn't allow us cron jobs. i thought
this would be trivial.



On Nov 11, 5:21 pm, AD7six [EMAIL PROTECTED] wrote:
 On Nov 11, 1:33 pm, technicaltitch [EMAIL PROTECTED] wrote:
 snip

 Why would you not use mysqldump and a cron job?

 AD


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



Giving multiple objects in a view

2007-11-11 Thread Arne-Kolja Bachstein

Hi there,

atm I am trying to implement a feature to upload multiple images with
an article. Apart from the few tutorials I found covering this topic,
I have a much more basic question about that:

When I'm associating the Images model to my Article model (hasMany), I
can simply use something like $this-Article-Image-save() to access/
save it. But what if I want to give multiple files, primarily fromt he
view point?

I have sort of the following code:

?php
 echo $form-create('Article');
 // [...]
 // Image fields
 $maxImg = Configure::read('App.classifieds_addarticle_maximg');

 for ($i = 0; $i  $maxImg; $i++)
 {
   echo $form-file('ArticleImage'); // what to do in this loop to
create an array or whatever can be used?
 }

 echo $form-submit(__('add_article', true));
 echo $form-end();
?

So how could I create an array of file inputs or something, that is
also passed to the controller as an array, so I could save() them in a
for loop or something?

Of course, any help is very welcome :-)

Thanks in advance

Arne


--~--~-~--~~~---~--~~
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: unbind a behavior / ActsAs

2007-11-11 Thread AD7six



On Nov 11, 7:49 pm, Zoltan [EMAIL PROTECTED] wrote:
 I'm doing a save on a model inside a controller to update one field,
 however it is triggering a behavior attached to that model. Is there a
 way to temporarily (like unbind) disable this ActAs so it isn't
 called.

 Zoltanwww.yyztech.ca

https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/behaviors/tree.php?rev=5912#L123

and put something like:

function enableNameOfBehavior($model, $enable = null) {
if ($enable !== null) {
$this-settings[$model-name]['enabled'] = $enable;
}
return $this-settings[$model-name]['enabled'];
}

in your behavior such that you have a means to edit this parameter.

hth,

AD


--~--~-~--~~~---~--~~
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: unbind a behavior / ActsAs

2007-11-11 Thread francky06l

There is also something about this there :

http://www.sanisoft.com/blog/2007/06/26/attach-detach-behaviors-at-run-time-in-cakephp-models/


On Nov 11, 8:58 pm, AD7six [EMAIL PROTECTED] wrote:
 On Nov 11, 7:49 pm, Zoltan [EMAIL PROTECTED] wrote:

  I'm doing a save on a model inside a controller to update one field,
  however it is triggering a behavior attached to that model. Is there a
  way to temporarily (like unbind) disable this ActAs so it isn't
  called.

  Zoltanwww.yyztech.ca

 https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/beh...

 and put something like:

 function enableNameOfBehavior($model, $enable = null) {
 if ($enable !== null) {
 $this-settings[$model-name]['enabled'] = $enable;
 }
 return $this-settings[$model-name]['enabled'];
 }

 in your behavior such that you have a means to edit this parameter.

 hth,

 AD


--~--~-~--~~~---~--~~
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: String concatenation not working

2007-11-11 Thread Steve Boyd


then changes your host.  there is incredibly cheap hosting everywhere
(well within the USA anyhow) that allows you cron jobs + all the other
bells and whistles


On Nov 12, 8:37 am, technicaltitch [EMAIL PROTECTED] wrote:
 because it's for a bolivian volunteer organization we're using
 incredibly cheap hosting which doesn't allow us cron jobs. i thought
 this would be trivial.

 On Nov 11, 5:21 pm, AD7six [EMAIL PROTECTED] wrote:

  On Nov 11, 1:33 pm, technicaltitch [EMAIL PROTECTED] wrote:
  snip

  Why would you not use mysqldump and a cron job?

  AD


--~--~-~--~~~---~--~~
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: $html-tagValue deprecated

2007-11-11 Thread Grant Cox

$html-value('Model.field');


On Nov 11, 4:17 pm, dm [EMAIL PROTECTED] wrote:
 $html-tagValue is deprecated in 1.2.  What should I use instead ?
 $this-data[model][field] ?

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



get/put/delete/post HTTP requests in CakePHP 1.2

2007-11-11 Thread Aaron Shafovaloff

I saw the following at 
http://www.xml.com/pub/a/2007/01/24/whats-new-in-prototype-15.html

---

The standard XMLHttpRequest object at the heart of Ajax functionality
only allows HTTP GET and POST methods, but RESTfully-designed web
applications often call for the lesser-used methods, like PUT and
DELETE. Until browsers support the full range of HTTP methods,
Prototype offers a compromise: tunneling those methods over POST, by
including a _method query parameter with the request. You can now
specify the intended HTTP method with the method option on all Ajax
functions (the default is POST). Methods other than GET or POST will
actually be requested with POST, but will have a _method query
parameter appended to the request URL. For example:

// Creates a POST request to /feeds/1.rss?_method=PUT
new Ajax.Request('/feeds/1.rss', { method:'put', postBody:myXML,
contentType:'application/rss+xml' });

Of course, the server side of the application must be written to
understand this convention as well, but if you use Rails, you'll get
the behavior for free.

---

Then I saw this at http://prototypejs.org/api/ajax/options

As a Ruby On Rails special, Prototype also reacts to other verbs (such
as 'put' and 'delete' by actually using 'post' and putting an extra
'_method' parameter with the originally requested method in there.

---

I was wondering if, like Rails, CakePHP had this feature?


--~--~-~--~~~---~--~~
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: get/put/delete/post HTTP requests in CakePHP 1.2

2007-11-11 Thread Aaron Shafovaloff

I just found this in dispatcher.php:

if (isset($params['form']['_method'])) {
if (isset($_SERVER)  !empty($_SERVER)) {
$_SERVER['REQUEST_METHOD'] = 
$params['form']['_method'];
} else {
$_ENV['REQUEST_METHOD'] = 
$params['form']['_method'];
}
unset($params['form']['_method']);
}


On Nov 11, 4:37 pm, Aaron  Shafovaloff [EMAIL PROTECTED] wrote:
 I saw the following 
 athttp://www.xml.com/pub/a/2007/01/24/whats-new-in-prototype-15.html

 ---

 The standard XMLHttpRequest object at the heart of Ajax functionality
 only allows HTTP GET and POST methods, but RESTfully-designed web
 applications often call for the lesser-used methods, like PUT and
 DELETE. Until browsers support the full range of HTTP methods,
 Prototype offers a compromise: tunneling those methods over POST, by
 including a _method query parameter with the request. You can now
 specify the intended HTTP method with the method option on all Ajax
 functions (the default is POST). Methods other than GET or POST will
 actually be requested with POST, but will have a _method query
 parameter appended to the request URL. For example:

 // Creates a POST request to /feeds/1.rss?_method=PUT
 new Ajax.Request('/feeds/1.rss', { method:'put', postBody:myXML,
 contentType:'application/rss+xml' });

 Of course, the server side of the application must be written to
 understand this convention as well, but if you use Rails, you'll get
 the behavior for free.

 ---

 Then I saw this athttp://prototypejs.org/api/ajax/options

 As a Ruby On Rails special, Prototype also reacts to other verbs (such
 as 'put' and 'delete' by actually using 'post' and putting an extra
 '_method' parameter with the originally requested method in there.

 ---

 I was wondering if, like Rails, CakePHP had this feature?


--~--~-~--~~~---~--~~
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: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Grant Cox

The reason it works in the first controller is because it is not
reading from the cookie itself - it also saves the data to a local
variable and it is reading back from that.  Because there is no
automatic serialization going on, only strings are written to the
cookie - so a complex data type will never work in your second
controller (or after refreshing the page, or whatever so that it does
actually read the cookie).

I can't think of any reason that it would not work without encryption
though...


--~--~-~--~~~---~--~~
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: How to find comment count for each post?

2007-11-11 Thread Adam Royle

I would keep the comment count in a field of its own in the posts
table (eg. comments_count), and update the value automatically
whenever a comment is saved or deleted. The beauty of this code is
that you don't need to change your controller code in any way (unless
you are updating the table using raw queries or using deleteAll(),
which doesn't use callbacks during the operation (yet)).

Please note this code is off-the-cuff and untested, but I do a similar
thing in one of my projects.


class Comment extends AppModel {

var $name = 'Comment';
var $belongsTo = array('Post');

var $_tempPostId;

function afterSave($created) {
$this-updateCommentCount($this-data['Comment']['post_id']);
}

function beforeDelete() {
$this-_tempPostId = $this-field('post_id');
return true;
}

function afterDelete() {
if ($this-_tempPostId) {
$this-updateCommentCount($this-_tempPostId);
$this-_tempPostId = null;
}
}

function updateCommentCount($post_id) {
$count = $this-findCount(array('post_id' = $post_id));
$this-Post-save( array('id' = $post_id, 'comments_count' =
$count) );
}

}


Cheers,
Adam

On Nov 10, 1:55 pm, Action [EMAIL PROTECTED] wrote:
 I want to be able to retrieve multiple blog posts as well as the
 comment count for each post. I do not want to retrieve the comments
 themselves, just the comment count.

 This is what I have so far:

 $this-Post-unbindModel(array('hasMany' = array('Comment')));

 $this-set('data', $this-Post-find('all', array('order' = 'created
 DESC')));

 I unbound the model association so it wouldn't pull the comments in
 the query. How can I make it so the find() as also grabs the comment
 count for each post it is grabbing?

 If I kept the association it would work, but I would have to also pull
 all of the comment data as well, which is something I don't want to
 do.

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



[Jobs]: Seeking CakePHP/CSS/JS Programmer

2007-11-11 Thread Staple

Hi,

I have a web app project I am seeking a contract programmer to build.
It is a 6 screen application, relatively simple but like all these
things has to work seamlessly and have a good data structure.

I am in the process of developing the screen layouts and DB structure
and am seeking somebody who...

- Speaks English (I'm in New Zealand)
- Can help me critique my DB structure before we start developing
- Develop the app in Cake with a small amount of JS for some form
handling
- Create the CSS (or I can do this and provide)

Anybody interested please email [EMAIL PROTECTED]

Many thanks,

Gwilym


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



.htaccess problem

2007-11-11 Thread [EMAIL PROTECTED]

in my cakephp

i want to do some url rewrite but whenever i put some url rule on my
htaccess it gives (none)500 error

my url is

http://www.xaprio.com/Client/work/PHPcake/shop?sn=alb=harish

and i want

http://www.xaprio.com/Client/work/PHPcake/shop/a/lb/harish

shop is my function in a controller

plz help me
thanx in advance


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