What does “select((select(s),$|=1)[0])” do in Perl?

It’s a nasty little idiom for setting autoflush on a filehandle other than STDOUT. select() takes the supplied filehandle and (basically) replaces STDOUT with it, and it returns the old filehandle when it’s done. So (select($s),$|=1) redirects the filehandle (remember select returns the old one), and sets autoflush ($| = 1). It does this in … Read more

Rails 3 – select with Include?

There is a select method in ARel, but you must use the correct table names (i.e. plural and beware if you have polymorphic models or if you’re using set_table_name or some other similar non-standard practice) @items = Item. select(‘users.name’, ‘users.created_at’, ‘orders.created_at’, ‘suppliers.name’, ‘agents.name’, ‘manufacturers.name’). where(:users => { :fulfilled => true }). includes(:orders => [:supplier, :agent], … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)