conditions

Wordpress category if-condition not working

I have a wordpress-generated page where I need some posts (in a specific category) to have a 'Sign up' button. But when I add the conditioning code, found in this helpsheet, the page just shows this error: 'Parse error: syntax error, unexpected '<' in /home006/sub008/sc74101-DVGF/gadebold.dk/wp-content/themes/gadebold/single.php on line...

Rails created_at find condition...

I'm attempting to sum daily purchase amounts for a given user. @dates is an array of 31 dates. I need the find condition to compare a date from the array to the created_at date of the purchases. What I'm doing below compares the exact DateTime for the create_at column. I need it to look at the day itself, not the DateTime. How can I wr...

rails conditional find based on datetime with timezone

I have a rails (2.3.4) application and want to send users a daily update via mail. To make things more comfortable, users can choose the time when they want their daily mail. My question: how should I store and more importantly lookup this time so as users' time zone, in particular daylight savings are respected? Currently, we save a 'p...

MySQL JOIN with IF conditions.

Hi, I want to get some results via query simillar to: SELECT * FROM users LEFT JOIN IF (users.type = '1', 'private','company') AS details ON users.id = details.user_id WHERE users.id = 1 Any ideas? ...

Rails find :conditions

I have a Reservation model that I'm searching for with three fields. The container_id must always be self.id but as confirmed and auto_confirmed only one needs to be true. I have the following but it doesn't perform what I need: Reservation.find(:all, :conditions => ['container_id = ? AND confirmed = ? OR auto_confirm = ?', self.id, ...

Problem with excluding conditions in complex cakephp model

I'm fairly new to cakephp and I'm having a problem with a complicated find function on my models. I have a number of Groups each containing a number of Users, and each group can make a number of Orders. Each order consists of a number of OrderAmounts which contain an amount and a user_id (relating to a User). I have a find which finds ...

conditions without repeats

Hi i'm using this for getting data: Topic.find(:all, :include => ..., :conditions => @core ? ["cores_topics.id = ? AND visible = 1 AND (distance < ? OR cores.id IN (?))",@core.id, @user_location[3].to_i, @user_friends] : ["visible = 1 AND (distance < ? OR cores.id IN (?))", @user_location[3].to_i, @user_friends], ... how can i rewri...

Jquery: How to find a link in a page based on its href attribute?

Hi Everybody, I am trying to find the first link of my page which url fit to "AAA" (example). I first try to get the links with this href: $('a[href$="AAA"]') Then selec the first one: $('a[href$="AAA"]')[0] Then target the title attribute of this link $('a[href$="AAA"]')[0].attr("title"); But all of this return me "undefi...

Multiple filter conditions on same field in reporting services

I have a report model in reporting services containing 3 tables: Persons Backgrounds PersonBackgrounds The content of the tables are: Persons (ID, NAME) 1, John Doe 2, Jane Doe Backgrounds (ID, BACKGROUND) 1, Female 2, Male 3, Single 4, Married PersonBackgrounds (PERSONID, BACKGROUNDID) 1, 2 1, 3 If i create a new ...

How do I filter or find a Model based on a method in that Model?

Hi, I have a controller which is looking for a set of Contacts from the Contacts table. Currently it looks like this: @contacts = @campaign.contacts.find(:all, :order => "date_entered ASC") The method in the contact.rb (Model) is this: def status return if statuses.empty? a= statuses.find(:last).status << ' (' << statuses.fin...

Rails conditions equal to one of an array- Syntax Errors

Hi I am trying to understand why I get a syntax error for this: :conditions => ["rank = ? and primaries.relationship = ?", ['CPT','SFC'], "Spouse"] I need to check "rank" against an Array of options. Seems like this should be pretty simple, any suggestions? ...

MySQL condition

I'm still pretty new with MySQL and I don't know the best way to do this. I have a table with incremented values, and if the values exceed a certain limit, I'd like to know. So lets say I have this table with a current column and capacity column. A row in current is incremented by user input and I want to know when the value in a curren...

What is wrong with this condition?

i getting errors if one of my conditions is: $conditions[] = array("PublicationNumeration.publication_numerations_published_date" => '2006-01-01' ); what is wrong with this condition? but everything works ok with $conditions[] = array("PublicationNumeration.publication_numerations_published_date" => '2006' ); ... but that's not a...

Need some help with the conditions in CakePHP!

I have three models linked in this manner: Item->Order->Payment Order hasMany Item Order hasOne Payment Now, I am paginating Items and want to add a condition in it to find only items of that order which has payment of a particular id. I hope that makes sense :P I added the condition as: array('Payment.id'=>$id) but it doesn't w...

if no row return then it's false when using php with mysql

I noticed that a lot of tutorial instructions often have this code: $sql="SELECT * from table"; $num=mysql_num_rows(); if ($num > 0) { do something } Why do they have to use that condition "if ($num > 0)" when I write this code that I think is compact and readable: $sql="SELECT * from table"; $itExists=mysql_num_rows(); if ($itExis...

Rails: how to use conditions and only let the db look 100 records deep, I'm not looking for limit

I'm adding data to a db and I only need to check for duplicated data within the last 30 minuets or so. Data is getting added at about 10 entries per minuet so I only need search about 300 records. How can I get this in conditions with rails Model.find(:all, :conditions => [])? ...

creating a new variable using two columns when they satisfy certain conditions using R

Hi R experts, I am providing this example data to get my question across. aid=c(1,2,3,4,5,6,7,8,9,10) foson=c(0,1,2,0,6,9,0,0,3,0) fosof=c(0,0,2,3,0,0,0,5,0,0) data=data.frame(aid,foson,fosof) Now, I need to create a new variable (column) named data$hist with the following conditions: if foson==0 and fosof==0, then hist = 0; if foso...

find condition with imported Model

Hi, In my AppController I do: App::import('Model', 'Season'); $season = new Season(); $aktuelleSaison = $season->field('id', array('Season.is_aktuell'=> 1 )); $teams = $season->Team->find('list', array('conditions', array('Team.season_id' => 11))); debug($teams); Of course the season hasMany Team. The Problem is: The fired Qu...

CakePHP Multiple Conditions Not Working as Expected

I have a find() query with multiple conditions, but the returning array contains entries should be excluded by the conditions. I read in the CakePHP docs that the default operator is "AND", which should mean that the results have to meet every condition, right? Here is my code, in case something is wrong with that... $this->set('object...

ActiveRecord Mixing Condition + Better Way to Write This

Is there a better way to write this I have A Condition which previous Look Very clean and easy to understand like Account.first.websites.last.users.find(:all, :conditions => {:country => "XYZ",:status => "Single",:admin => nil) Now the big problem is that user with admin = false is not picked up. i.e I want all the user...