• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I address a new column in a "joined" table?

#1
[eluser]Grego606[/eluser]
I am trying to add a where() condition. The targeted column is 'micro' in a table called 'songs'.

How do I read and update 'micro'?

I attempted to add 'micro' =>$label->song->micro to the "where" array.

Code:
function label($label_id)
    {
        $label = new Label();
        $label->where(array('id' => $label_id,'micro' =>$label->song->micro));
        
        $label->get();
        
        ...
        ...
I get a php error that says:
Quote:Error Number: 1054

Unknown column '0' in 'where clause'

SELECT bands.* FROM (`bands`) LEFT JOIN `bands_labels` ON bands.id = band_id LEFT JOIN `labels` ON labels.id = label_id WHERE `0` IS NULL AND labels.id = 1 ORDER BY `sort`
The Datamapper file:
Code:
class Label extends DataMapper {
    
    var $has_many = array('band' => 'bands', 'song' => 'songs', 'file' => 'files');

    function Label($condition = array())
    {
        parent::DataMapper($condition);
    }
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.