Search Results

Search found 3111 results on 125 pages for 'labeled statements'.

Page 8/125 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • wordpress conditional statements

    - by codedude
    I am using this code in wordpress to display different content when different pages are loaded. I have 5 pages on the site called Home, Bio, Work, Contact and Notes. The Notes page is being used as a blog. Here is the code I am using. <?php if (is_page('contact')) { ?> get in touch with me <?php } elseif (is_single()) { ?> a note from me <?php } elseif (is_page('notes')) { ?> the notes of me <?php } else { ?> the <?php the_title(); ?> of me <?php } ?> So if it the contact page, it displays "get in touch with me" and if it is a single blog post page it displays "a note from me". However this is where I have a problem. The next statement should display "the notes of me" when it is on the Notes page. However, this does not happen. Instead it shows the default content which is in the "else" statement. any idea on why this is happening?

    Read the article

  • Profiling statements inside a User-Defined Function

    - by Craig Walker
    I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together. In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't being logged at all. Because of this, I'm not getting useful data on which tables & indexes are being hit. I'd like to feed this info into the Database Tuning Advisor for some indexing advice. Is there any way (short of unwrapping the queries themselves) to log the tables called by UDFs in Profiler?

    Read the article

  • javascript AOP advice to statements

    - by Paul
    Some javascript libraries, such as JQuery and Dojo, provide AOP APIs that can introduce before, after, or around advice to a function. Just wondering whether there is any javascript AOP libraries can introduce such advices to an individual statement?

    Read the article

  • Dynamic find methods Vs conditional statements in rails

    - by piemesons
    Hello Student.find_all_by_name_and_status(‘mohit’, 1) As this will create a exception 'No method exception' first then it will be handled by dynamic Method handler and this will not Student.find(:all, :conditions => [‘name = ? and status = ?’ ‘mohit’, 1]) Does Student.find(1) Will generate method missing exception and will it prevent SQL injection?

    Read the article

  • running code if try statements were successful in python

    - by None
    I was wondering if in python there was a simple way to run code if a try statement was successful that wasn't in the try statement itself. Is that what the else or finally commands do (I didn't understand their documentation)? I know I could use code like this: successful = False try: #code that might fail successful = True except: #error handling if code failed if successful: #code to run if try was successful that isn't part of try but I was wondering if there was a shorter way .

    Read the article

  • How to eliminate "else-if" statements.

    - by Stremlenye
    My function get QueryString from some Web page as a string. I need to parce it, to check, what strategy i must use. Now my code looks ugly (i think so): public QueryStringParser(string QueryString) { if (string.IsNullOrEmpty(QueryString)) { this._mode = Mode.First; } else if (QueryString.Contains(_FristFieldName) && !QueryString.Contains(_SecondFieldName)) { this._mode = Mode.Second; } else if (!QueryString.Contains(_FristFieldName) && QueryString.Contains(_SecondFieldName)) { this._mode = Mode.Third; } else { throw new ArgumentException("QueryString has wrong format"); } } There must'n't be both FieldNames in one QueryString. How to change this code to be mo readable.

    Read the article

  • Selecting fields in SQL Select statements (Dumbest SQL Question)

    - by JC
    Hello all, Here's a dumb question which I can't find an answer to: I have a table which contains 20 fields, a few of which are date/time. I am interested in pulling all the fields. I would like to pull the datetime fields using the to_char function but don't want to individually list out all the other fields. Is there an easy way to do this? I tried select *, tochar(dtfield) as dt2 and select tochar(dtfield) as dt2, * and both give errors. Thanks for all your help! JC

    Read the article

  • combining two select statements to return one result

    - by DalivDali
    I need to combine the results for two select queries from two view tables, from which I am performing calculations. Perhaps there is an easier way to perform a query using if...else - any pointers? Essentially I need to divide everything by 'ar.time_ratio' under the condition in sql query 1, and ignore that for query 2. SELECT gs.traffic_date, gs.domain_group, gs.clicks/ar.time_ratio as 'Scaled_clicks', gs.visitors/ar.time_ratio as 'scaled_visitors', gs.revenue/ar.time_ratio as 'scaled_revenue', (gs.revenue/gs.clicks)/ar.time_ratio as 'scaled_average_cpc', (gs.clicks)/(gs.visitors)/ar.time_ratio as 'scaled_ctr', gs.average_rpm/ar.time_ratio as 'scaled_rpm', (((gs.revenue)/(gs.visitors))/ar.time_ratio)*1000 as "Ecpm" FROM group_stats gs, v_active_ratio ar WHERE ar.group_id=gs.domain_group and SELECT gs.traffic_date, gs.domain_group, gs.clicks, gs.visitors, gs.revenue, (gs.revenue/gs.clicks) as 'average_cpc', (gs.clicks)/(gs.visitors) as 'average_ctr', gs.average_rpm, ((gs.revenue)/(gs.visitors))*1000 as "Ecpm" FROM group_stats gs, v_active_ratio ar where not ar.group_id=gs.domain_group

    Read the article

  • gcov and switch statements

    - by Matt
    I'm running gcov over some C code with a switch statement. I've written test cases to cover every possible path through that switch statement, but it still reports a branch in the switch statement as not taken and less than 100% on the "Taken at least once" stat. Here's some sample code to demonstrate: #include "stdio.h" void foo(int i) { switch(i) { case 1:printf("a\n");break; case 2:printf("b\n");break; case 3:printf("c\n");break; default: printf("other\n"); } } int main() { int i; for(i=0;i<4;++i) foo(i); return 0; } I built with "gcc temp.c -fprofile-arcs -ftest-coverage", ran "a", then did "gcov -b -c temp.c". The output indicates eight branches on the switch and one (branch 6) not taken. What are all those branches and how do I get 100% coverage?

    Read the article

  • NHibernate: How to show the generated SQL-statements in the windows console

    - by Rookian
    return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(c => c .Database(Database) .TrustedConnection() .Server(Server) ).ShowSql()) .ExposeConfiguration(c => c.SetProperty("current_session_context_class", "web")) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TeamMap>()).BuildConfiguration(); I have a web application. This configuration does not work. I also have a Console application that shall be responsible to write out all generated SQL. How can I get the generated SQL commands? Thanks in advance!

    Read the article

  • Why do switch statements continue after case

    - by John W.
    After evaluating a case in a switch statement in Java (and I am sure other languages) the following case's are also evaluated unless a control statement like break, or return is used. I understand this is probably an implementation detail, but what is/are the reasons for having this functionality happen? Thanks!

    Read the article

  • Need to combine common result of two select statements

    - by Anup
    i have to select the common coloumns c1 ,c2,c3 from result of two sql satements. 1) select c1, c2, c3,count(c3) from (select * from form_name where data_created >'1273446000' and data_creazione<'1274569200') group by c1,c2, c3 having count(c3)>1 2) select c1, c2, c3,count(c3) from (select * from form_name where data_created>'1272236400' and data_creazione<'1274569200') group by c1,c2, c3 having count(c3)>2 I need to select c1,c2,c3 all same and common found in both the result of query. how could this be done...could anyone help please?

    Read the article

  • How to make multiple queries with PHP prepared statements (Commands out of sync error)

    - by Tirithen
    I'm trying to run three MySQL queries from a PHP script, the first one works fine, but on the second one I get the "Commands out of sync; you can’t run this command now" error. I have managed to understand that I need to "empty" the resultset before preparing a new query but I can't seem to understand how. I thought that $statement-close; would do that for me. Here is the relevant part of the code: <?php $statement = $db_conn->prepare("CALL getSketches(?,?)"); // Prepare SQL routine to check if user is accepted $statement->bind_param("is", $user_id, $loaded_sketches); // Bind variables to send $statement->execute(); // Execute the query $statement->bind_result( // Set return varables $id, $name, $description, $visibility, $createdby_id, $createdby_name, $createdon, $permission ); $new_sketches_id = array(); while($statement->fetch()) { $result['newSketches'][$id] = array( "name" => $name, "description" => $description, "visibility" => $visibility, "createdById" => $createdby_id, "createdByName" => $createdby_name, "createdOn" => $createdon, "permission" => $permission ); $new_sketches_id[] = $id; } $statement->close; // Close satement $new_sketches_ids = implode(",", $new_sketches_id); // Get the new sketches elements $statement = $db_conn->prepare("CALL getElements(?,'',?,'00000000000000')"); // Prepare SQL routine to check if user is accepted // The script crashes here with $db_conn->error // "Commands out of sync; you can't run this command now" $statement->bind_param("si", $new_sketches_ids, $user_id); // Bind variables to send $statement->execute(); // Execute the query $statement->bind_result( // Set return varables $id, $user_id, $type, $attribute_d, $attribute_stroke, $attribute_strokeWidth, $sketch_id, $createdon ); while($statement->fetch()) { $result['newSketches'][$sketch_id]['newElements']["u".$user_id."e".$id] = array( "type" => $type, "d" => $attribute_d, "stroke" => $attribute_stroke, "strokeWidth" => $attribute_strokeWidth, ); } $statement->close; // Close satement ?> How can I make the second query without closing and reopening the entire database connection?

    Read the article

  • Prepared Statements in MySql 5.1

    - by Ronen
    This one is really puzzling. I can't seem to be able to run any prepared statement on MySql 5.1. Any simple select I'm writing runs fine but when I'm trying to run it from a prepared statement I'm getting Query returned no result set. What Am I doing wrong? Exmaple: prepare s from 'select * from t'; execute s; Thanks!

    Read the article

  • Objective-C "if" statements not retaining

    - by seanny94
    I know the title of this question is a bit confusing, but here it goes anyway: I'm creating an NSString after an if statement but it just doesn't seem to want to retain outside of the statement. My conditional looks like this: if ([[password stringValue] isEqualToString:@""]) { NSString *pwd = [[NSString alloc]initWithString:@"password"]; } else { NSString *pwd = [[NSString alloc]initWithFormat:@"%@", [password stringValue]]; } ... and I call pwd later in the script like this: NSArray *arguments; arguments = [NSArray arrayWithObjects: ip, pwd, nil]; [task setArguments: arguments]; But when I do so in this way, the first snippet returns a warning of Unused variable 'pwd' and the latter call ends up in an error of 'pwd' undeclared. What am I doing wrong here? Thanks in advance. ;)

    Read the article

  • Advanced Where Statements in Linq to Entity Framework

    - by JimJams
    Hi, I am wanting to create a Where statement within my Linq statement, but have hit a bit of a stumbling block. I would like to split a string value, and then search using each array item in the Where clause. In my normal Sql statement I would simply loop through the string array, and build up there Where clause then either pass this to a stored procedure, or just execute the sql string. But am not sure how to do this with Linq to Entity? ( From o In db.TableName Where o.Field LIKE Stringvalue Select o ).ToList() Hope you can help. Thanks in advance!

    Read the article

  • Delphi Typed Constants in Case Statements

    - by Andreas Rejbrand
    What is the most elegant (or least ugly) way of using typed constants in a case statement in Delphi? That is, assume for this question that you need to declare a typed constant as in const MY_CONST: cardinal = $12345678; ... Then the Delphi compiler will not accept case MyExpression of MY_CONST: { Do Something }; ... end; but you need to write case MyExpression of $12345678: { Do Something }; ... end; which is error-prone, hard to update, and not elegant. Is there any trick you can employ to make the compiler insert the value of the constant (preferably by checking the value of the constant under const in the source code, but maybe by looking-up the value at runtime)? We assume here that you will not alter the value of the "constant" at runtime.

    Read the article

  • Is it bad to have multiple return statements?

    - by scot
    Hi, I have a code somethg like below: int method(string a ,int b , int c){ if(cond1) return -1; if(cond2 || cond3) return 3; if(cond1 && cond2) return 0; else return -999; } Does it perform badly when compared to having multiple if else and have single return?

    Read the article

  • Statements and state

    - by FredOverflow
    Is there any deeper meaning in the fact that the word "statement" starts with the word "state", or is that just a curious coincidence? Note that english is not my native language, so the answer might be obvious to you, but not me ;)

    Read the article

  • How to define using statements in web.config?

    - by Hasan Gürsoy
    I'm using MySql in my asp.net project. But I don't want to type every "using MySql.Data.MySqlClient;" statement in every aspx.cs file. How can I define this lines in web.config file? I've defined some namespaces like below but this only works for aspx pages: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="false" targetFramework="4.0"/> <pages> <namespaces> <add namespace="System.Web.Configuration"/> <add namespace="MySql.Data"/> <add namespace="MySql.Data.MySqlClient"/> </namespaces> </pages> </system.web> </configuration>

    Read the article

  • Refactoring many nested ifs or chained if statements

    - by Icarus
    Hi, I have an object with large number of similar fields (like more than 10 of them) and I have to assign them values from an array of variable length. The solution would be either a huge nested bunch of ifs based on checking length of array each time and assigning each field OR a chain of ifs checking on whether the length is out of bounds and assigning each time after that check. Both seem to be repetitive. Is there a better solution ?

    Read the article

  • Control statements in Haskell?

    - by Nathan
    I am just beginning Haskell, but from all the online tutorials I've found I can't seem to find if there is one accepted way to do a conditional control statement. I have seen if-else, guards, and pattern matching, but they all seem to accomplish the same thing. Is there one generally accepted/faster/more efficient way than the rest?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >