Thanks for the help so far. I made your recommended changes. As for
the ->findAll() issue, I've found that in dbo_source.php on line 577,
$linkModel is null, which in turn means the db connection stuff on
line 580+ fails because $linkModel->useDbConfig doesn't exist on a non-
object. Do you think this is a bug in the 1.2.0.5427alpha code, or am
I missing a declaration somewhere? (Maybe this is related to why $this-
>Image->Tag->save() doesn't work... Image not having any saved
references to Tag?)

Here's a var_dump of the Image model, just before the error:
object(Image)#8 (42) { ["name"]=>  string(5) "Image" ["table"]=>
string(6) "images" ["useTable"]=>  string(6)
"images" ["useDbConfig"]=>  string(7)
"default" ["hasAndBelongsToMany"]=>  array(1) { ["Tag"]=>  array(1)
{ [0]=>  string(3) "Tag" } } ["hashKey"]=>  string(0) "" ["parent"]=>
bool(false) ["displayField"]=>  NULL ["id"]=>  bool(false) ["data"]=>
array(0) { } ["primaryKey"]=>  NULL ["_schema"]=>  object(Set)#17 (2)
{ ["value"]=>  array(3) { ["id"]=>  array(6) { ["type"]=>  string(7)
"integer" ["null"]=>  bool(false) ["default"]=>  NULL ["length"]=>
int(10) ["key"]=>  string(7) "primary" ["extra"]=>  string(14)
"auto_increment" } ["name"]=>  array(4) { ["type"]=>  string(6)
"string" ["null"]=>  bool(false) ["default"]=>  string(0)
"" ["length"]=>  NULL } ["created"]=>  array(4) { ["type"]=>
string(4) "date" ["null"]=>  bool(false) ["default"]=>  string(0)
"" ["length"]=>  NULL } } ["_log"]=>  NULL } ["_tableInfo"]=>
object(Set)#18 (2) { ["value"]=>  array(3) { [0]=>  array(7)
{ ["name"]=>  string(2) "id" ["type"]=>  string(7)
"integer" ["null"]=>  bool(false) ["default"]=>  NULL ["length"]=>
int(10) ["key"]=>  string(7) "primary" ["extra"]=>  string(14)
"auto_increment" } [1]=>  array(5) { ["name"]=>  string(4)
"name" ["type"]=>  string(6) "string" ["null"]=>  bool(false)
["default"]=>  string(0) "" ["length"]=>  NULL } [2]=>  array(5)
{ ["name"]=>  string(7) "created" ["type"]=>  string(4)
"date" ["null"]=>  bool(false) ["default"]=>  string(0)
"" ["length"]=>  NULL } } ["_log"]=>  NULL } ["validate"]=>  array(0)
{ } ["validationErrors"]=>  array(0) { } ["tablePrefix"]=>  NULL
["currentModel"]=>  NULL ["tableToModel"]=>  array(0) { }
["modelToTable"]=>  array(0) { } ["keyToTable"]=>  array(0) { }
["alias"]=>  array(0) { } ["logTransactions"]=>  bool(false)
["transactional"]=>  bool(false) ["cacheQueries"]=>  bool(false)
["belongsTo"]=>  array(0) { } ["hasOne"]=>  array(0) { }
["hasMany"]=>  array(0) { } ["actsAs"]=>  NULL ["behaviors"]=>
array(0) { } ["cacheSources"]=>  bool(true) ["__behaviorMethods"]=>
array(0) { } ["recursive"]=>  int(1) ["order"]=>  NULL
["__associationKeys"]=>  array(4) { ["belongsTo"]=>  array(6) { [0]=>
string(9) "className" [1]=>  string(10) "foreignKey" [2]=>  string(10)
"conditions" [3]=>  string(6) "fields" [4]=>  string(5) "order" [5]=>
string(12) "counterCache" } ["hasOne"]=>  array(6) { [0]=>  string(9)
"className" [1]=>  string(10) "foreignKey" [2]=>  string(10)
"conditions" [3]=>  string(6) "fields" [4]=>  string(5) "order" [5]=>
string(9) "dependent" } ["hasMany"]=>  array(11) { [0]=>  string(9)
"className" [1]=>  string(10) "foreignKey" [2]=>  string(10)
"conditions" [3]=>  string(6) "fields" [4]=>  string(5) "order" [5]=>
string(5) "limit" [6]=>  string(6) "offset" [7]=>  string(9)
"dependent" [8]=>  string(9) "exclusive" [9]=>  string(11)
"finderQuery" [10]=>  string(12) "counterQuery" }
["hasAndBelongsToMany"]=>  array(14) { [0]=>  string(9)
"className" [1]=>  string(9) "joinTable" [2]=>  string(4)
"with" [3]=>  string(10) "foreignKey" [4]=>  string(21)
"associationForeignKey" [5]=>  string(10) "conditions" [6]=>
string(6) "fields" [7]=>  string(5) "order" [8]=>  string(5)
"limit" [9]=>  string(6) "offset" [10]=>  string(6) "unique" [11]=>
string(11) "finderQuery" [12]=>  string(11) "deleteQuery" [13]=>
string(11) "insertQuery" } } ["__associations"]=>  array(4) { [0]=>
string(9) "belongsTo" [1]=>  string(6) "hasOne" [2]=>  string(7)
"hasMany" [3]=>  string(19) "hasAndBelongsToMany" }
["__backAssociation"]=>  array(0) { } ["__insertID"]=>  NULL
["__numRows"]=>  NULL ["__affectedRows"]=>  NULL ["_log"]=>  NULL
["clean"]=>  object(Sanitize)#11 (0) { } ["Tag"]=>  &NULL }



Looking at the dbo_source.php code again, the '$linkModel =& $model-
>{$assoc};' uses the key part of the ["hasAndBelongsToMany"] model,
but even if {$assoc} == 'Tag', $linkModel still comes back as NULL.


On Sep 15, 11:21 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> > The generate_browser() function in the controller is where things are
> > falling over.
>
> > The goal is simply for an uploaded image to have many tags associated
> > with it, which the user can enter as comma separated list in a
> > textbox.
>
> I can't see anything wrong with your code actually, what is the final
> state of $this->data before you save?
>
> Do all your Tags get created correctly?
>
> Your tables are not set in the conventional Cake way, which means you
> should be using $displayField in your model constructors to inform
> cake what to use for things like 'generateList'.
>
> You might want to try:
>
> // images
> id
> name (instead of file_name)
> created
> modified
>
> // tags
> id
> name
> created
> modified
>
> Your join table is correct btw
>
> > In the future, I want to be able to search for a Tag and get
> > a list of Images with that Tag associated to them. I also just wish to
> > be able to get a list of Images (with or without associated Tag data).
>
> to accomplish this you need to create the association in your Tag
> model back to images.
>
> Sorry not to be more help!
>
> thanks,
>
> Jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to