For (1) - I removed the 'containable' part completely - falling back
to only pure HABTM on Item into Tag.
On my dev environments, a find('all) on Item retrieved all Items and
all the tags for the items.
On the hosting, though, looking at the SQL debug output and log - only
the one SELECT statement
was called - to retrieve the Items. No subsequent statements to the
Tag and items_tags tables.
(All cache was deleted, tables re-created and all project was deleted
and re-uploaded to the server,
so I don't think it has any caching issues).
A note about the 'contain' use - I know there are different ways to
use it, but I don't think this is the issue,
again - this definitely worked on my local environment.
Playing around a little, I removed the HABTM from the models, and did
a bindModel on the fly:
$this->Item->bindModel(array(
'hasAndBelongsToMany' => array(
'Tag' => array(
'className'=>'Tag',
'joinTable'=>'items_tags',
'foreignKey'=>'item_id',
'associationForeignKey' =>'tag_id',
'uniq'=>true
)
)));
and that works as expected on the shared host.
Could it be that the shared hosting adds a suffix to the tables which
is
somehow 'transparent' to the application, so that suffix_items and
suffix_tags are translated correctly
but the link table (items_tags) is somehow referred to
suffix_items_suffix_tags instead of suffix_items_tags ?
This is a long shot - but I can't think of anything else...
As for issue (2) - you were right. I found it before reading your
reply but still - spot on! Thanks heaps
On Sep 25, 7:06 am, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Sep 23, 2010 at 7:49 PM, Thomas <raz.do...@gmail.com> wrote:
> > Hi,
> > I have a Cake application that's running perfectly on my local
> > machines - Windows7 and Os/X (both have XAMPP 1.7.1 with PHP 5.2.9).
> > I tried to deploy it on a shared hosting environment (PHP 5.2.14) and
> > it is mostly ok.. However, I get two failures that I can't resolve and
> > would really appreciate any help.
>
> > 1) I am using 'Containable' in the following manner:
> > In app/app_model.php, I specify
> > var $actsAs = array('containable');
>
> > In the 'Item' model: var $hasAndBelongsToMany = array('Tag');
>
> > In the 'Tag' model: var $hasAndBelongsToMany = array('Item');
>
> > In my controller:
> > $this->Item->contain('Tag');
> > $items = $this->Item->find('all',array(
> > 'order' =>array('Item.created DESC'),
> > 'contain' => array('Tag.id','Tag.name')));
>
> > This works very well on my local machines, but once deployed to the
> > shared hosting I get:
>
> > Warning (512): Model "Item" is not associated with model "Tag" [CORE/
> > cake/libs/model/behaviors/containable.php, line 363]
>
> > And the SQL generated only gets the items - not the tags.
>
> Weird. First thing I'd do is delete everything in app/tmp/models dir.
> Next, check that your model files on the server are up to date. Ditto
> for the DB tables.
>
> And, possibly, there's an issue with that Containable syntax. That's
> not how I use it.Do you have the exact same version of Cake on the
> server as locally? FWIW, this is how I use Containable:
>
> $items = $this->Item->find(
> 'all',
> array(
> 'order' =>array('Item.created DESC'),
> 'contain' => array(
> 'Tag' => array(
> 'fields' => array(
> 'Tag.id',
> 'Tag.name'
> )
> )
> )
> )
> );
>
> > 2) I am also using the markdown parser class.
> > I have Markdown_Parser.php in my vendors folder, defining a class
> > called Markdown_Parser.
> > load it in a component like so:
>
> > if (!class_exists('Markdown_Parser')) {
> > App::import('Vendor', 'MarkdownParser');
> > }
> > $this->parser = new Markdown_Parser(); //This is line 36
>
> > When I call the parser from the controller I get:
>
> > Fatal error: Class 'Markdown_Parser' not found in /home/narp/
> > public_html/yarp/app/controllers/components/markdown.php on line 36
>
> Try passing the path, relative to vendors dir, to the class. eg.
>
> App::import('Vendor', 'phpThumb', false, null, 'phpThumb/phpthumb.class.php');- Hide quoted text -
>
> - Show quoted text -
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment