Caching-Strategy for Model-Data in Cake3

2014-07-22 Thread Sven
Hi all!

I am wondering what your opinions are about the best way to tackle caching 
within Cake 3 within the model-layer.

When writing custom finders for your tables you can have 3 approaches:

   1. Write small, easy to read, understand-, maintain- and testable 
   finder-methods which you then might chain
   2. Write somewhat bigger custom find-methods which allow for more 
   dedicated caching and a thinner model-layer
   3. Combine both approaches (i.e: combine the small bits to the big one)

Lets say you are writing a method for twitter that shows the very last 
tweet for a given user and you know that this will be often used.

You could then have something like

   - findPublished, findLatest, findForUser
   
or

   - findLatestPublishedForUser

in your Tweet-Table-Class.

What would you do? I'm also asking to check if I understood the purpose of 
the Query-Builder correctly. Having the ability to combine different 
find-methods seems great!

I hope it's okay to ask those questions here. I think that this question 
might not have been problem-orientated enough for SO.

Best regards
Sven

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.x - Fixtures, import records ?

2014-07-22 Thread José Lorenzo
Yes, the feature was removed. You can, though, override the _getRecords() 
or insert() method to do whatever you like. For instance, I have .sql files 
stored in my project that I load in the insert() method.

On Monday, July 21, 2014 7:49:09 PM UTC+2, Thomas von Hassel wrote:

 Hey 

 Is it true that the importing of records is gone from fixtures in 3.x ? 

 I have a dataset that is prohibitive to define manually in the fixture so 
 i have been relying on having it be imported with the 'records' = true key 


 /thomas 



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Controller class could not be found

2014-07-22 Thread José Lorenzo
It means that someone is requesting missing images in your app and the 
robots.txt file. Creating the missing files will fix the problem

On Monday, July 21, 2014 10:00:31 PM UTC+2, Rafael Queiroz wrote:

 Hi,

 I have problem in my application using CakePHP 2.2.5:

 2014-07-21 16:35:53 Error: [MissingControllerException] Controller class 
 ImgController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest), 
 Object(CakeResponse))

 2014-07-21 16:48:20 Error: [MissingControllerException] Controller class 
 Robots.txtController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest), 
 Object(CakeResponse))


 Any ideas ?

 -- 

 Rafael F. Queiroz
  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.x - Fixtures, import records ?

2014-07-22 Thread Thomas von Hassel
Yeah, that was i was going to do, i was just wondering why that feature got the 
axe ?

/thomas

On 22 Jul 2014, at 09:53, José Lorenzo jose@gmail.com wrote:

 Yes, the feature was removed. You can, though, override the _getRecords() or 
 insert() method to do whatever you like. For instance, I have .sql files 
 stored in my project that I load in the insert() method.
 
 On Monday, July 21, 2014 7:49:09 PM UTC+2, Thomas von Hassel wrote:
 Hey 
 
 Is it true that the importing of records is gone from fixtures in 3.x ? 
 
 I have a dataset that is prohibitive to define manually in the fixture so i 
 have been relying on having it be imported with the 'records' = true key 
 
 
 /thomas 
 
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Load Time

2014-07-22 Thread Ravi Saxena(Nethues)
Hi Sudhir, 

Use this htaccess code in your main htaccess file. 

--- 

ifModule mod_headers.c
Header set Connection keep-alive 
/ifModule

# compress text, html, javascript, css, xml: 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 

# Or, compress certain file types by extension: 
files *.html
SetOutputFilter DEFLATE 
/files

ExpiresActive On 
ExpiresDefault access plus 1 week 
ExpiresByType text/html access plus 1 week 
ExpiresByType image/x-icon access plus 1 week 
ExpiresByType image/gif access plus 1 week 
ExpiresByType image/jpeg access plus 1 week 
ExpiresByType image/png access plus 1 week 
ExpiresByType text/css access plus 1 week 
ExpiresByType text/javascript access plus 1 week 
ExpiresByType application/x-javascript access plus 1 week 


 
# GZIP COMPRESSION # 
 
SetOutputFilter DEFLATE 
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml 
application/x-javascript application/x-httpd-php 
BrowserMatch ^Mozilla/4 gzip-only-text/html 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip 
Header append Vary User-Agent env=!dont-vary 

ifModule mod_gzip.c
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ 
mod_gzip_item_include handler ^cgi-script$ 
mod_gzip_item_include mime ^text/.* 
mod_gzip_item_include mime ^application/x-javascript.* 
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
/ifModule
--End 

Thanks 
Ravi 

On Monday, July 21, 2014 4:26:26 PM UTC+5:30, Sudhir Pandey wrote:

 Hi ,
 How I will increase load time of website in cakephp?

 Regards

 Sudhir 


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Load Time

2014-07-22 Thread nethues
Hi Sudhir,

Use this htaccess code in your main htaccess file.

---

ifModule mod_headers.c
Header set Connection keep-alive
/ifModule

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
files *.html
SetOutputFilter DEFLATE
/files

ExpiresActive On
ExpiresDefault access plus 1 week
ExpiresByType text/html access plus 1 week
ExpiresByType image/x-icon access plus 1 week
ExpiresByType image/gif access plus 1 week
ExpiresByType image/jpeg access plus 1 week
ExpiresByType image/png access plus 1 week
ExpiresByType text/css access plus 1 week
ExpiresByType text/javascript access plus 1 week
ExpiresByType application/x-javascript access plus 1 week



# GZIP COMPRESSION #

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml
application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary

ifModule mod_gzip.c
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
/ifModule
--End

Thanks
Ravi




--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Load-Time-tp5718919p5718927.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: how to display html content without exist view file

2014-07-22 Thread nethues
Use routing rules to create dynamic pages so you do not need to create views
for every pages, just create single view and use routing.

Thanks
Ravi



--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/how-to-display-html-content-without-exist-view-file-tp5718911p5718928.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.x - Fixtures, import records ?

2014-07-22 Thread José Lorenzo
It was very buggy and slow and what it did could be replaced easier with 
specific queries for each driver. My personal plan is to do that in another 
plugin like I did for y current Fixturize plugin in 2.x.
Maybe you want to help with that? :)

On Tuesday, July 22, 2014 9:58:49 AM UTC+2, Thomas von Hassel wrote:

 Yeah, that was i was going to do, i was just wondering why that feature 
 got the axe ?

 /thomas

 On 22 Jul 2014, at 09:53, José Lorenzo jose@gmail.com wrote:

 Yes, the feature was removed. You can, though, override the _getRecords() 
 or insert() method to do whatever you like. For instance, I have .sql files 
 stored in my project that I load in the insert() method.

 On Monday, July 21, 2014 7:49:09 PM UTC+2, Thomas von Hassel wrote:

 Hey 

 Is it true that the importing of records is gone from fixtures in 3.x ? 

 I have a dataset that is prohibitive to define manually in the fixture so 
 i have been relying on having it be imported with the 'records' = true key 


 /thomas 


 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Caching-Strategy for Model-Data in Cake3

2014-07-22 Thread José Lorenzo
I often create plenty small custom finders I can combine. Also I find 
myself creating very specialized finders which sole responsibility is to 
combine multiple others.
for example in an application of mine I have a findForNewsletter() which 
composes findActive(), findSubscribed(), findForLocation() and a few 
others. Those specialized
finders I use in bigger routines like a controller or a shell.


On Tuesday, July 22, 2014 2:13:16 AM UTC+2, Sven wrote:

 Hi all!

 I am wondering what your opinions are about the best way to tackle caching 
 within Cake 3 within the model-layer.

 When writing custom finders for your tables you can have 3 approaches:

1. Write small, easy to read, understand-, maintain- and testable 
finder-methods which you then might chain
2. Write somewhat bigger custom find-methods which allow for more 
dedicated caching and a thinner model-layer
3. Combine both approaches (i.e: combine the small bits to the big one)

 Lets say you are writing a method for twitter that shows the very last 
 tweet for a given user and you know that this will be often used.

 You could then have something like

- findPublished, findLatest, findForUser

 or

- findLatestPublishedForUser

 in your Tweet-Table-Class.

 What would you do? I'm also asking to check if I understood the purpose of 
 the Query-Builder correctly. Having the ability to combine different 
 find-methods seems great!

 I hope it's okay to ask those questions here. I think that this question 
 might not have been problem-orientated enough for SO.

 Best regards
 Sven


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Selecting specific data from the database through multiple relations

2014-07-22 Thread David Yell
*Synopsis*
Trying to select data from multiple related models explicitly is hard in 
the framework due to it's focus on always providing a left join. Even with 
Containable and Linkable it's not always possible, without a manual query, 
to select records where their related record has a condition. Such as 
selecting all Posts where a Tag is authored by User x. It seems odd to me 
that the framework should return empty related model records or, if using 
linkable not return all the related records. I am starting this thread to 
discuss solutions, tips, tricks and techniques for achieving this 
functionality as I do not feel that either Containable or Linkable 
accurately cover this use-case. It may well be that case that some more 
guidance is needed in the documentation for this specific type of query.

*The problem*
You would like to select from primary model but only if related models 
conditions are met. The primary model should only be included in the result 
set if the related model conditions are met. With a single related model 
this is quite easy using Linkable. However when you start trying to achieve 
this across HABTM, hasManyThrough or two or three nested models the problem 
grows in complexity.

A few examples, might make things clearer.

*Hotel hasMany HotelFeature belongsTo Feature*
You need to select hotels which have n number of specific features. The 
hotel must have all of the features listed to be included in the dataset.

*Post hasMany PostsTag belongsTo Tag belongsTo User*
You need to find all the posts which have tags created by a certain user.

*Hotel belongsTo City belongsTo Province belongsTo Country*
You need to select all the cities in a country where there is a hotel.

I'm sure there are some other use-cases, but these are the ones of the top 
of my head. As you can see it's usually selecting a primary record where a 
related record matches a certain condition, but where the related record is 
a multiple.

*Possible solutions*
This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. 
The only real thing that I can think of is either more enhancements to 
Containable or Linkable really. However I am not sure how to approach such 
a problem. I was told once in an interview that any more than five joins 
will impact performance in MySQL (could be fiction), so obviously there is 
a performance concern with highly normalised databases. Concerns which are 
ignored by Containable with it's multiple queries across many models - a 
solution which I think was devised to solve this problem.

*Discussion*
The idea of the thread was to discuss potential solutions really. I wanted 
to air my thoughts on a problem which I have hit many times with my current 
project and have had to battle against. Usually using manual joins, but in 
most cases I end up using Containable and filtering the data in the 
front-end `foreach()` which isn't elegant, clever or clean.

I'm sure this kind of issue will have been addressed with the new ORM in 
3.x, but I need to find a decent solution to this problem which will be 
flexible enough to be beneficial to lots of different projects, and to 
other Cake users. We are all taught to normalise, and it makes sense to do 
so, but this issue keeps nagging at me and I'm finding it frustrating. I 
don't feel that the framework is helping me solve such a problem.

If you read to here, thanks, have a biscuit and share your thoughts. How do 
you get around this issue?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.x - Fixtures, import records ?

2014-07-22 Thread Thomas von Hassel
sure :)

On 22 Jul 2014, at 10:33, José Lorenzo jose@gmail.com wrote:

 It was very buggy and slow and what it did could be replaced easier with 
 specific queries for each driver. My personal plan is to do that in another 
 plugin like I did for y current Fixturize plugin in 2.x.
 Maybe you want to help with that? :)
 
 On Tuesday, July 22, 2014 9:58:49 AM UTC+2, Thomas von Hassel wrote:
 Yeah, that was i was going to do, i was just wondering why that feature got 
 the axe ?
 
 /thomas
 
 On 22 Jul 2014, at 09:53, José Lorenzo jose@gmail.com wrote:
 
 Yes, the feature was removed. You can, though, override the _getRecords() or 
 insert() method to do whatever you like. For instance, I have .sql files 
 stored in my project that I load in the insert() method.
 
 On Monday, July 21, 2014 7:49:09 PM UTC+2, Thomas von Hassel wrote:
 Hey 
 
 Is it true that the importing of records is gone from fixtures in 3.x ? 
 
 I have a dataset that is prohibitive to define manually in the fixture so i 
 have been relying on having it be imported with the 'records' = true key 
 
 
 /thomas 
 
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.
 
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Selecting specific data from the database through multiple relations

2014-07-22 Thread José Lorenzo
Not sure why linkable is not working for you. Did you make sure to set 
'type' = 'INNER' in the linkable definition for that model? That will 
filter records from the parent model according to the conditions in the 
association.

On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote:

 *Synopsis*
 Trying to select data from multiple related models explicitly is hard in 
 the framework due to it's focus on always providing a left join. Even with 
 Containable and Linkable it's not always possible, without a manual query, 
 to select records where their related record has a condition. Such as 
 selecting all Posts where a Tag is authored by User x. It seems odd to me 
 that the framework should return empty related model records or, if using 
 linkable not return all the related records. I am starting this thread to 
 discuss solutions, tips, tricks and techniques for achieving this 
 functionality as I do not feel that either Containable or Linkable 
 accurately cover this use-case. It may well be that case that some more 
 guidance is needed in the documentation for this specific type of query.

 *The problem*
 You would like to select from primary model but only if related models 
 conditions are met. The primary model should only be included in the result 
 set if the related model conditions are met. With a single related model 
 this is quite easy using Linkable. However when you start trying to achieve 
 this across HABTM, hasManyThrough or two or three nested models the problem 
 grows in complexity.

 A few examples, might make things clearer.

 *Hotel hasMany HotelFeature belongsTo Feature*
 You need to select hotels which have n number of specific features. The 
 hotel must have all of the features listed to be included in the dataset.

 *Post hasMany PostsTag belongsTo Tag belongsTo User*
 You need to find all the posts which have tags created by a certain user.

 *Hotel belongsTo City belongsTo Province belongsTo Country*
 You need to select all the cities in a country where there is a hotel.

 I'm sure there are some other use-cases, but these are the ones of the top 
 of my head. As you can see it's usually selecting a primary record where a 
 related record matches a certain condition, but where the related record is 
 a multiple.

 *Possible solutions*
 This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome ORM. 
 The only real thing that I can think of is either more enhancements to 
 Containable or Linkable really. However I am not sure how to approach such 
 a problem. I was told once in an interview that any more than five joins 
 will impact performance in MySQL (could be fiction), so obviously there is 
 a performance concern with highly normalised databases. Concerns which are 
 ignored by Containable with it's multiple queries across many models - a 
 solution which I think was devised to solve this problem.

 *Discussion*
 The idea of the thread was to discuss potential solutions really. I wanted 
 to air my thoughts on a problem which I have hit many times with my current 
 project and have had to battle against. Usually using manual joins, but in 
 most cases I end up using Containable and filtering the data in the 
 front-end `foreach()` which isn't elegant, clever or clean.

 I'm sure this kind of issue will have been addressed with the new ORM in 
 3.x, but I need to find a decent solution to this problem which will be 
 flexible enough to be beneficial to lots of different projects, and to 
 other Cake users. We are all taught to normalise, and it makes sense to do 
 so, but this issue keeps nagging at me and I'm finding it frustrating. I 
 don't feel that the framework is helping me solve such a problem.

 If you read to here, thanks, have a biscuit and share your thoughts. How 
 do you get around this issue?


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Selecting specific data from the database through multiple relations

2014-07-22 Thread David Yell
I wasn't aware that Linkable took different types of joins.

On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote:

 Not sure why linkable is not working for you. Did you make sure to set 
 'type' = 'INNER' in the linkable definition for that model? That will 
 filter records from the parent model according to the conditions in the 
 association.

 On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote:

 *Synopsis*
 Trying to select data from multiple related models explicitly is hard in 
 the framework due to it's focus on always providing a left join. Even with 
 Containable and Linkable it's not always possible, without a manual query, 
 to select records where their related record has a condition. Such as 
 selecting all Posts where a Tag is authored by User x. It seems odd to me 
 that the framework should return empty related model records or, if using 
 linkable not return all the related records. I am starting this thread to 
 discuss solutions, tips, tricks and techniques for achieving this 
 functionality as I do not feel that either Containable or Linkable 
 accurately cover this use-case. It may well be that case that some more 
 guidance is needed in the documentation for this specific type of query.

 *The problem*
 You would like to select from primary model but only if related models 
 conditions are met. The primary model should only be included in the result 
 set if the related model conditions are met. With a single related model 
 this is quite easy using Linkable. However when you start trying to achieve 
 this across HABTM, hasManyThrough or two or three nested models the problem 
 grows in complexity.

 A few examples, might make things clearer.

 *Hotel hasMany HotelFeature belongsTo Feature*
 You need to select hotels which have n number of specific features. The 
 hotel must have all of the features listed to be included in the dataset.

 *Post hasMany PostsTag belongsTo Tag belongsTo User*
 You need to find all the posts which have tags created by a certain user.

 *Hotel belongsTo City belongsTo Province belongsTo Country*
 You need to select all the cities in a country where there is a hotel.

 I'm sure there are some other use-cases, but these are the ones of the 
 top of my head. As you can see it's usually selecting a primary record 
 where a related record matches a certain condition, but where the related 
 record is a multiple.

 *Possible solutions*
 This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome 
 ORM. The only real thing that I can think of is either more enhancements to 
 Containable or Linkable really. However I am not sure how to approach such 
 a problem. I was told once in an interview that any more than five joins 
 will impact performance in MySQL (could be fiction), so obviously there is 
 a performance concern with highly normalised databases. Concerns which are 
 ignored by Containable with it's multiple queries across many models - a 
 solution which I think was devised to solve this problem.

 *Discussion*
 The idea of the thread was to discuss potential solutions really. I 
 wanted to air my thoughts on a problem which I have hit many times with my 
 current project and have had to battle against. Usually using manual joins, 
 but in most cases I end up using Containable and filtering the data in the 
 front-end `foreach()` which isn't elegant, clever or clean.

 I'm sure this kind of issue will have been addressed with the new ORM in 
 3.x, but I need to find a decent solution to this problem which will be 
 flexible enough to be beneficial to lots of different projects, and to 
 other Cake users. We are all taught to normalise, and it makes sense to do 
 so, but this issue keeps nagging at me and I'm finding it frustrating. I 
 don't feel that the framework is helping me solve such a problem.

 If you read to here, thanks, have a biscuit and share your thoughts. How 
 do you get around this issue?



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Selecting specific data from the database through multiple relations

2014-07-22 Thread David Yell
I have managed to solve some issues, like counting hotels using things 
similar to the following model method.

/**
 * Find a list of all the regions and how many hotels are in each region
 * 
 * @return array
 */
 public function regionWithHotelCount() {
 return $this-find('all', [
 'link' = [
 'CountriesRegion' = [
 'fields' = ['id', 'country_id', 'region_id'],
 'Country' = [
 'fields' = ['id'],
 'State' = [
 'fields' = ['id'],
 'City' = [
 'fields' = ['id'],
 'Hotel' = [
 'fields' = ['id'],
 ]
 ]
 ]
 ]
 ]
 ],
 'fields' = ['Region.slug', 'CountriesRegion.region_id', 'Region.name', 
'COUNT(Hotel.id) 
as NumHotels'],
 'group' = 'CountriesRegion.region_id'
 ]);
 }


On Tuesday, 22 July 2014 11:57:59 UTC+1, David Yell wrote:

 I wasn't aware that Linkable took different types of joins.

 On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote:

 Not sure why linkable is not working for you. Did you make sure to set 
 'type' = 'INNER' in the linkable definition for that model? That will 
 filter records from the parent model according to the conditions in the 
 association.

 On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote:

 *Synopsis*
 Trying to select data from multiple related models explicitly is hard in 
 the framework due to it's focus on always providing a left join. Even with 
 Containable and Linkable it's not always possible, without a manual query, 
 to select records where their related record has a condition. Such as 
 selecting all Posts where a Tag is authored by User x. It seems odd to me 
 that the framework should return empty related model records or, if using 
 linkable not return all the related records. I am starting this thread to 
 discuss solutions, tips, tricks and techniques for achieving this 
 functionality as I do not feel that either Containable or Linkable 
 accurately cover this use-case. It may well be that case that some more 
 guidance is needed in the documentation for this specific type of query.

 *The problem*
 You would like to select from primary model but only if related models 
 conditions are met. The primary model should only be included in the result 
 set if the related model conditions are met. With a single related model 
 this is quite easy using Linkable. However when you start trying to achieve 
 this across HABTM, hasManyThrough or two or three nested models the problem 
 grows in complexity.

 A few examples, might make things clearer.

 *Hotel hasMany HotelFeature belongsTo Feature*
 You need to select hotels which have n number of specific features. The 
 hotel must have all of the features listed to be included in the dataset.

 *Post hasMany PostsTag belongsTo Tag belongsTo User*
 You need to find all the posts which have tags created by a certain user.

 *Hotel belongsTo City belongsTo Province belongsTo Country*
 You need to select all the cities in a country where there is a hotel.

 I'm sure there are some other use-cases, but these are the ones of the 
 top of my head. As you can see it's usually selecting a primary record 
 where a related record matches a certain condition, but where the related 
 record is a multiple.

 *Possible solutions*
 This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome 
 ORM. The only real thing that I can think of is either more enhancements to 
 Containable or Linkable really. However I am not sure how to approach such 
 a problem. I was told once in an interview that any more than five joins 
 will impact performance in MySQL (could be fiction), so obviously there is 
 a performance concern with highly normalised databases. Concerns which are 
 ignored by Containable with it's multiple queries across many models - a 
 solution which I think was devised to solve this problem.

 *Discussion*
 The idea of the thread was to discuss potential solutions really. I 
 wanted to air my thoughts on a problem which I have hit many times with my 
 current project and have had to battle against. Usually using manual joins, 
 but in most cases I end up using Containable and filtering the data in the 
 front-end `foreach()` which isn't elegant, clever or clean.

 I'm sure this kind of issue will have been addressed with the new ORM in 
 3.x, but I need to find a decent solution to this problem which will be 
 flexible enough to be beneficial to lots of different projects, and to 
 other Cake users. We are all taught to normalise, and it makes sense to do 
 so, but this issue keeps nagging at me and I'm finding it frustrating. I 
 don't feel that the framework is helping me solve such a problem.

 If you read to here, thanks, have a biscuit and share your thoughts. How 
 do you get around this issue?



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: Selecting specific data from the database through multiple relations

2014-07-22 Thread David Yell
Managed to solve it with something like this in some cases.

/**
 * Find a list of all the regions and how many hotels are in each region
 * 
 * @return array
 */
public function regionWithHotelCount() {
return $this-find('all', [
'link' = [
'CountriesRegion' = [
'fields' = ['id', 'country_id', 'region_id'],
'Country' = [
'fields' = ['id'],
'State' = [
'fields' = ['id'],
'City' = [
'fields' = ['id'],
'Hotel' = [
'fields' = ['id'],
]
]
]
]
]
],
'fields' = ['Region.slug', 'CountriesRegion.region_id', 
'Region.name', 'COUNT(Hotel.id) as NumHotels'],
'group' = 'CountriesRegion.region_id'
]);
}


On Tuesday, 22 July 2014 11:57:59 UTC+1, David Yell wrote:

 I wasn't aware that Linkable took different types of joins.

 On Tuesday, 22 July 2014 11:50:38 UTC+1, José Lorenzo wrote:

 Not sure why linkable is not working for you. Did you make sure to set 
 'type' = 'INNER' in the linkable definition for that model? That will 
 filter records from the parent model according to the conditions in the 
 association.

 On Tuesday, July 22, 2014 10:57:14 AM UTC+2, David Yell wrote:

 *Synopsis*
 Trying to select data from multiple related models explicitly is hard in 
 the framework due to it's focus on always providing a left join. Even with 
 Containable and Linkable it's not always possible, without a manual query, 
 to select records where their related record has a condition. Such as 
 selecting all Posts where a Tag is authored by User x. It seems odd to me 
 that the framework should return empty related model records or, if using 
 linkable not return all the related records. I am starting this thread to 
 discuss solutions, tips, tricks and techniques for achieving this 
 functionality as I do not feel that either Containable or Linkable 
 accurately cover this use-case. It may well be that case that some more 
 guidance is needed in the documentation for this specific type of query.

 *The problem*
 You would like to select from primary model but only if related models 
 conditions are met. The primary model should only be included in the result 
 set if the related model conditions are met. With a single related model 
 this is quite easy using Linkable. However when you start trying to achieve 
 this across HABTM, hasManyThrough or two or three nested models the problem 
 grows in complexity.

 A few examples, might make things clearer.

 *Hotel hasMany HotelFeature belongsTo Feature*
 You need to select hotels which have n number of specific features. The 
 hotel must have all of the features listed to be included in the dataset.

 *Post hasMany PostsTag belongsTo Tag belongsTo User*
 You need to find all the posts which have tags created by a certain user.

 *Hotel belongsTo City belongsTo Province belongsTo Country*
 You need to select all the cities in a country where there is a hotel.

 I'm sure there are some other use-cases, but these are the ones of the 
 top of my head. As you can see it's usually selecting a primary record 
 where a related record matches a certain condition, but where the related 
 record is a multiple.

 *Possible solutions*
 This is where I am unsure. My SQL-fu is weak thanks to Cake's awesome 
 ORM. The only real thing that I can think of is either more enhancements to 
 Containable or Linkable really. However I am not sure how to approach such 
 a problem. I was told once in an interview that any more than five joins 
 will impact performance in MySQL (could be fiction), so obviously there is 
 a performance concern with highly normalised databases. Concerns which are 
 ignored by Containable with it's multiple queries across many models - a 
 solution which I think was devised to solve this problem.

 *Discussion*
 The idea of the thread was to discuss potential solutions really. I 
 wanted to air my thoughts on a problem which I have hit many times with my 
 current project and have had to battle against. Usually using manual joins, 
 but in most cases I end up using Containable and filtering the data in the 
 front-end `foreach()` which isn't elegant, clever or clean.

 I'm sure this kind of issue will have been addressed with the new ORM in 
 3.x, but I need to find a decent solution to this problem which will be 
 flexible enough to be beneficial to lots of different projects, and to 
 other Cake users. We are all taught to normalise, and it makes sense to do 
 so, but this issue keeps nagging at me and I'm finding it frustrating. I 
 don't feel that the framework is helping me solve such a problem.

 If you read to here, thanks, have a biscuit and share your thoughts. How 
 do you get around this issue?



-- 
Like Us 

Re: Controller class could not be found

2014-07-22 Thread Rafael Queiroz
Thanks José, but i need catching exception if file not exist.
The problem is dangerous, many the requests connection timed out in
rackspace.


On Tue, Jul 22, 2014 at 4:54 AM, José Lorenzo jose@gmail.com wrote:

 It means that someone is requesting missing images in your app and the
 robots.txt file. Creating the missing files will fix the problem


 On Monday, July 21, 2014 10:00:31 PM UTC+2, Rafael Queiroz wrote:

 Hi,

 I have problem in my application using CakePHP 2.2.5:

 2014-07-21 16:35:53 Error: [MissingControllerException] Controller class
 ImgController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest),
 Object(CakeResponse))

 2014-07-21 16:48:20 Error: [MissingControllerException] Controller class
 Robots.txtController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest),
 Object(CakeResponse))


 Any ideas ?

 --

 Rafael F. Queiroz

  --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
Atenciosamente,

Rafael F. Queiroz

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Controller class could not be found

2014-07-22 Thread José Lorenzo
Are you sure the problem is not because you are linking to many broken 
images in your source?

On Tuesday, July 22, 2014 4:34:09 PM UTC+2, Rafael Queiroz wrote:

 Thanks José, but i need catching exception if file not exist.
 The problem is dangerous, many the requests connection timed out in 
 rackspace.


 On Tue, Jul 22, 2014 at 4:54 AM, José Lorenzo jose@gmail.com wrote:

 It means that someone is requesting missing images in your app and the 
 robots.txt file. Creating the missing files will fix the problem


 On Monday, July 21, 2014 10:00:31 PM UTC+2, Rafael Queiroz wrote:

 Hi,

 I have problem in my application using CakePHP 2.2.5:

 2014-07-21 16:35:53 Error: [MissingControllerException] Controller class 
 ImgController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest), 
 Object(CakeResponse))

 2014-07-21 16:48:20 Error: [MissingControllerException] Controller class 
 Robots.txtController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest), 
 Object(CakeResponse))


 Any ideas ?

 -- 

 Rafael F. Queiroz
  
  -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Atenciosamente,

 Rafael F. Queiroz
  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Controller class could not be found

2014-07-22 Thread Rafael Queiroz
Maybe, the first time happened that yesterday, the project is available 4
months ago, no peak was identified in server, some content just created
like everyday (12 new images), no changes in version.
Do not understand how this problem came to take the site down.


On Tue, Jul 22, 2014 at 11:43 AM, José Lorenzo jose@gmail.com wrote:

 Are you sure the problem is not because you are linking to many broken
 images in your source?


 On Tuesday, July 22, 2014 4:34:09 PM UTC+2, Rafael Queiroz wrote:

 Thanks José, but i need catching exception if file not exist.
 The problem is dangerous, many the requests connection timed out in
 rackspace.


 On Tue, Jul 22, 2014 at 4:54 AM, José Lorenzo jose@gmail.com wrote:

 It means that someone is requesting missing images in your app and the
 robots.txt file. Creating the missing files will fix the problem


 On Monday, July 21, 2014 10:00:31 PM UTC+2, Rafael Queiroz wrote:

 Hi,

 I have problem in my application using CakePHP 2.2.5:

 2014-07-21 16:35:53 Error: [MissingControllerException] Controller
 class ImgController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest),
 Object(CakeResponse))

 2014-07-21 16:48:20 Error: [MissingControllerException] Controller
 class Robots.txtController could not be found.
 #0 /app/webroot/index.php(92): Dispatcher-dispatch(Object(CakeRequest),
 Object(CakeResponse))


 Any ideas ?

 --

 Rafael F. Queiroz

  --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google
 Groups CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




 --
 Atenciosamente,

 Rafael F. Queiroz

  --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
Atenciosamente,

Rafael F. Queiroz

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.x - Fixtures, import records ?

2014-07-22 Thread Thomas von Hassel
Do you just exec() out to the mysql client or how would you do this in the most 
correct way ?

/thomas


On 22 Jul 2014, at 09:53, José Lorenzo jose@gmail.com wrote:

 For instance, I have .sql files stored in my project that I load in the 
 insert() method.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0: defaultConnectionName doesn't create correct connection

2014-07-22 Thread Joe Theuerkauf
José:

Sorry for the delayed response. i've been getting burned out (and burned up 
with the weather), so i took a day to breathe.

i called $this-Captchas-defaultConnectionName() from inside the 
ContactsController:

public function index() {
 $this-loadModel('Captchas');
 // PS: i'm using the LogTrait in the class...
 $this-log('defaultConnectionName: ' . 
$this-Captchas-defaultConnectionName());

// ...
}


Output in error.log:

2014-07-23 01:16:55 Error: defaultConnectionName: default


Obviously, not what i was expecting. And that's the value whether i have 
CaptchasTable in the main Model/Table or in Model/Table/Website.

If you have further suggestions, please let me know. i know 3.0 is alpha so 
i do expect some breakage. But when the documentation is so brief  doesn't 
seem to work, it can be frustrating.
-joe


On Monday, 21 July 2014 04:08:18 UTC-4, José Lorenzo wrote:

 what is returned if you call $this-Captchas-defaultConnectionName() ?

 On Sunday, July 20, 2014 6:29:33 PM UTC+2, Joe Theuerkauf wrote:

 i tried this topic before, but the only response was for an older version 
 of Cake...

 i'm following this documentation:

 http://book.cakephp.org/3.0/en/orm/table-objects.html#configuring-connections

 i'm trying to keep a few tables that would be application-agnostic in a 
 different database. i'm not trying to create associations as mentioned in 
 #3463. i just need to query independent records from these tables.

 Here's what i have so far:
 // Config/app.php
 $config = [
 // ...
   'Datasources' = [
 'default' = [
   // Connection to this DB works.
   'database' = 'kodiak',
 ],
 'websites' = [
   // Connection is identical, except different 'database' value
   'database' = 'websites',
 ]
   ]
 // ...
 ];

 // Model/Table/Websites/CapchasTable.php
 class CaptchasTable extends Table {
 public static function defaultConnectionName () {
 return 'websites';
 }
 }

 // Controller/ContactsController.php
 public function index () {
 $this-loadModel('Captchas');

 $captcha = $this-Captchas-find('all', [
 'conditions' = [],
 'order' = 'RAND()',
 'limit' = 1
 ]);

 // etc.
 }

 Here's the error output:

 SQLSTATE[42S02]: Base table or view not found: 1146 Table 
 *'kodiak.captchas'* doesn't exist

 Error: An Internal Error Has Occurred.
 Stack Trace

 ROOT\vendor\cakephp\cakephp\src\Database\Schema\Collection.php line 
 113 → Cake\Database\Schema\Collection-_executeSql(string, array)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 323 → 
 Cake\Database\Schema\Collection-describe(string)
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 127 → 
 Cake\ORM\Table-schema()
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 110 → 
 Cake\ORM\Query-addDefaultTypes(Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 927 → 
 Cake\ORM\Query-__construct(Cake\Database\Connection, Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 724 → 
 Cake\ORM\Table-query()
 APP/Controller\ContactsController.php line 36 → 
 Cake\ORM\Table-find(string, array)
 [internal function] → App\Controller\ContactsController-index()
 ROOT\vendor\cakephp\cakephp\src\Controller\Controller.php line 373 → 
 ReflectionMethod-invokeArgs(App\Controller\ContactsController, array)
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 115 → 
 Cake\Controller\Controller-invokeAction()
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 87 → 
 Cake\Routing\Dispatcher-_invoke(App\Controller\ContactsController)
 ROOT\webroot\index.php line 37 → 
 Cake\Routing\Dispatcher-dispatch(Cake\Network\Request, 
 Cake\Network\Response)

 It doesn't seem to matter if CaptchasTable is in Model/Table or 
 Model/Table/Websites; loadModel('Captchas') doesn't throw errors either 
 way. But the find() call is throwing the error - *regardless where *
 CaptchasTable* is placed*. When it's commented, the page loads fine 
 (since i'm hitting this error, i haven't actually tried to USE any of the 
 Captcha data in my form yet).

 So the question is: why isn't defaultConnectionName setting up the 
 connection to the `websites` DB? What's missing? Is it missing 
 documentation  i need to do something more, or is this a bug?

 i'd appreciate any help before i post this to the Github issues. Thanks.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0: defaultConnectionName doesn't create correct connection

2014-07-22 Thread Joe Theuerkauf
Two addenda:

1. Does it make a difference that i'm loading a different Model that uses 
the 'default' connection *before* Captchas? i've been omitting it because i 
didn't think it was relevant. But maybe there's some failure to get the 
right defaultConnectionName() because both Models are loaded? It doesn't 
seem so at first glance, since i'm specifying $this-Captchas, but who 
knows...

2. My apologies for the jab above. i'm actually far less frustrated by 
occasional breakage from an alpha framework than i am by trying to unravel 
bugs  lack of activity in the production release of a popular front-end 
framework i use. Lots of other unrelated crap too. To say the least, it's 
been a long month.


On Tuesday, 22 July 2014 21:26:20 UTC-4, Joe Theuerkauf wrote:

 José:

 Sorry for the delayed response. i've been getting burned out (and burned 
 up with the weather), so i took a day to breathe.

 i called $this-Captchas-defaultConnectionName() from inside the 
 ContactsController:

 public function index() {
  $this-loadModel('Captchas');
  // PS: i'm using the LogTrait in the class...
  $this-log('defaultConnectionName: ' . 
 $this-Captchas-defaultConnectionName());

 // ...
 }


 Output in error.log:

 2014-07-23 01:16:55 Error: defaultConnectionName: default


 Obviously, not what i was expecting. And that's the value whether i have 
 CaptchasTable in the main Model/Table or in Model/Table/Website.

 If you have further suggestions, please let me know. i know 3.0 is alpha 
 so i do expect some breakage. But when the documentation is so brief  
 doesn't seem to work, it can be frustrating.
 -joe


 On Monday, 21 July 2014 04:08:18 UTC-4, José Lorenzo wrote:

 what is returned if you call $this-Captchas-defaultConnectionName() ?

 On Sunday, July 20, 2014 6:29:33 PM UTC+2, Joe Theuerkauf wrote:

 i tried this topic before, but the only response was for an older 
 version of Cake...

 i'm following this documentation:

 http://book.cakephp.org/3.0/en/orm/table-objects.html#configuring-connections

 i'm trying to keep a few tables that would be application-agnostic in a 
 different database. i'm not trying to create associations as mentioned in 
 #3463. i just need to query independent records from these tables.

 Here's what i have so far:
 // Config/app.php
 $config = [
 // ...
   'Datasources' = [
 'default' = [
   // Connection to this DB works.
   'database' = 'kodiak',
 ],
 'websites' = [
   // Connection is identical, except different 'database' value
   'database' = 'websites',
 ]
   ]
 // ...
 ];

 // Model/Table/Websites/CapchasTable.php
 class CaptchasTable extends Table {
 public static function defaultConnectionName () {
 return 'websites';
 }
 }

 // Controller/ContactsController.php
 public function index () {
 $this-loadModel('Captchas');

 $captcha = $this-Captchas-find('all', [
 'conditions' = [],
 'order' = 'RAND()',
 'limit' = 1
 ]);

 // etc.
 }

 Here's the error output:

 SQLSTATE[42S02]: Base table or view not found: 1146 Table 
 *'kodiak.captchas'* doesn't exist

 Error: An Internal Error Has Occurred.
 Stack Trace

 ROOT\vendor\cakephp\cakephp\src\Database\Schema\Collection.php line 
 113 → Cake\Database\Schema\Collection-_executeSql(string, array)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 323 → 
 Cake\Database\Schema\Collection-describe(string)
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 127 → 
 Cake\ORM\Table-schema()
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 110 → 
 Cake\ORM\Query-addDefaultTypes(Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 927 → 
 Cake\ORM\Query-__construct(Cake\Database\Connection, Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 724 → 
 Cake\ORM\Table-query()
 APP/Controller\ContactsController.php line 36 → 
 Cake\ORM\Table-find(string, array)
 [internal function] → App\Controller\ContactsController-index()
 ROOT\vendor\cakephp\cakephp\src\Controller\Controller.php line 373 → 
 ReflectionMethod-invokeArgs(App\Controller\ContactsController, array)
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 115 → 
 Cake\Controller\Controller-invokeAction()
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 87 → 
 Cake\Routing\Dispatcher-_invoke(App\Controller\ContactsController)
 ROOT\webroot\index.php line 37 → 
 Cake\Routing\Dispatcher-dispatch(Cake\Network\Request, 
 Cake\Network\Response)

 It doesn't seem to matter if CaptchasTable is in Model/Table or 
 Model/Table/Websites; loadModel('Captchas') doesn't throw errors either 
 way. But the find() call is throwing the error - *regardless where *
 CaptchasTable* is placed*. When it's commented, the page loads fine 
 (since i'm hitting this error, i haven't actually tried to USE any of the 
 Captcha data in my form yet).

 So the question is: why isn't defaultConnectionName setting up the 
 

Does CakePHP 2.5 support the HSTORE and ARRAY data types from PostgreSQL?

2014-07-22 Thread David Suna
We are looking into what framework to use for a new project. One of the 
requirements of the project is to use PostgreSQL and take advantage of the 
Postgres specific data types like HSTORE. Is that something that CakePHP 
supports?

Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0: defaultConnectionName doesn't create correct connection

2014-07-22 Thread Joe Theuerkauf
Okay, i fixated on this tonight  i think i got it to work. i put 
CaptchasTable back in App/Model/Table, and behold the class loads correctly 
(i forgot to adjust the namespace in the previous message).

However, before i do a happy dance, i'd like to know if it's *POSSIBLE* to 
organize my Models into subdirectories as i was attempting to do:

Model/Table/* : My project's main DB Table classes
Model/Table/Websites/* : Table classes from the Websites database, so 
they're not cluttering up my project's main tables... 
Model/Table//* : Similar if i need to connect to any other databases...

Can this be done at all?





On Tuesday, 22 July 2014 21:26:20 UTC-4, Joe Theuerkauf wrote:

 José:

 Sorry for the delayed response. i've been getting burned out (and burned 
 up with the weather), so i took a day to breathe.

 i called $this-Captchas-defaultConnectionName() from inside the 
 ContactsController:

 public function index() {
  $this-loadModel('Captchas');
  // PS: i'm using the LogTrait in the class...
  $this-log('defaultConnectionName: ' . 
 $this-Captchas-defaultConnectionName());

 // ...
 }


 Output in error.log:

 2014-07-23 01:16:55 Error: defaultConnectionName: default


 Obviously, not what i was expecting. And that's the value whether i have 
 CaptchasTable in the main Model/Table or in Model/Table/Website.

 If you have further suggestions, please let me know. i know 3.0 is alpha 
 so i do expect some breakage. But when the documentation is so brief  
 doesn't seem to work, it can be frustrating.
 -joe


 On Monday, 21 July 2014 04:08:18 UTC-4, José Lorenzo wrote:

 what is returned if you call $this-Captchas-defaultConnectionName() ?

 On Sunday, July 20, 2014 6:29:33 PM UTC+2, Joe Theuerkauf wrote:

 i tried this topic before, but the only response was for an older 
 version of Cake...

 i'm following this documentation:

 http://book.cakephp.org/3.0/en/orm/table-objects.html#configuring-connections

 i'm trying to keep a few tables that would be application-agnostic in a 
 different database. i'm not trying to create associations as mentioned in 
 #3463. i just need to query independent records from these tables.

 Here's what i have so far:
 // Config/app.php
 $config = [
 // ...
   'Datasources' = [
 'default' = [
   // Connection to this DB works.
   'database' = 'kodiak',
 ],
 'websites' = [
   // Connection is identical, except different 'database' value
   'database' = 'websites',
 ]
   ]
 // ...
 ];

 // Model/Table/Websites/CapchasTable.php
 class CaptchasTable extends Table {
 public static function defaultConnectionName () {
 return 'websites';
 }
 }

 // Controller/ContactsController.php
 public function index () {
 $this-loadModel('Captchas');

 $captcha = $this-Captchas-find('all', [
 'conditions' = [],
 'order' = 'RAND()',
 'limit' = 1
 ]);

 // etc.
 }

 Here's the error output:

 SQLSTATE[42S02]: Base table or view not found: 1146 Table 
 *'kodiak.captchas'* doesn't exist

 Error: An Internal Error Has Occurred.
 Stack Trace

 ROOT\vendor\cakephp\cakephp\src\Database\Schema\Collection.php line 
 113 → Cake\Database\Schema\Collection-_executeSql(string, array)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 323 → 
 Cake\Database\Schema\Collection-describe(string)
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 127 → 
 Cake\ORM\Table-schema()
 ROOT\vendor\cakephp\cakephp\src\ORM\Query.php line 110 → 
 Cake\ORM\Query-addDefaultTypes(Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 927 → 
 Cake\ORM\Query-__construct(Cake\Database\Connection, Cake\ORM\Table)
 ROOT\vendor\cakephp\cakephp\src\ORM\Table.php line 724 → 
 Cake\ORM\Table-query()
 APP/Controller\ContactsController.php line 36 → 
 Cake\ORM\Table-find(string, array)
 [internal function] → App\Controller\ContactsController-index()
 ROOT\vendor\cakephp\cakephp\src\Controller\Controller.php line 373 → 
 ReflectionMethod-invokeArgs(App\Controller\ContactsController, array)
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 115 → 
 Cake\Controller\Controller-invokeAction()
 ROOT\vendor\cakephp\cakephp\src\Routing\Dispatcher.php line 87 → 
 Cake\Routing\Dispatcher-_invoke(App\Controller\ContactsController)
 ROOT\webroot\index.php line 37 → 
 Cake\Routing\Dispatcher-dispatch(Cake\Network\Request, 
 Cake\Network\Response)

 It doesn't seem to matter if CaptchasTable is in Model/Table or 
 Model/Table/Websites; loadModel('Captchas') doesn't throw errors either 
 way. But the find() call is throwing the error - *regardless where *
 CaptchasTable* is placed*. When it's commented, the page loads fine 
 (since i'm hitting this error, i haven't actually tried to USE any of the 
 Captcha data in my form yet).

 So the question is: why isn't defaultConnectionName setting up the 
 connection to the `websites` DB? What's missing? Is it missing 
 documentation  i