Search Results

Search found 20401 results on 817 pages for 'null coalescing operator'.

Page 12/817 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Mysql Left Join Null Result

    - by Ozzy
    I have this query SELECT articles.*, users.username AS `user` FROM `articles` LEFT JOIN `users` ON articles.user_id = users.id ORDER BY articles.timestamp Basically it returns the list of articles and the username that the article is associated to. Now if there is no entry in the users table for a particular user id, the users var is NULL. Is there anyway to make it that if its null it returns something like "User Not Found"? or would i have to do this using php?

    Read the article

  • Can a constructor return a NULL value?

    - by Sanctus2099
    I know constructors don't "return" anything but for instance if I call CMyClass *object = new CMyClass() is there any way to make object to be NULL if the constructor fails? In my case I have some images that have to be loaded and if the file reading fails I'd like it to return null. Is there any way to do that? Thanks in advance.

    Read the article

  • Checking for a null int value from a Java ResultSet

    - by ian_scho_es
    In Java I'm trying to test for a null value, from a ResultSet, where the column is being cast to a primitive int type. int iVal; ResultSet rs = magicallyAppearingStmt.executeQuery(query); if (rs.next()) { if (rs.getObject("ID_PARENT") != null && !rs.wasNull()) { iVal = rs.getInt("ID_PARENT"); } } From the code fragment above, is there a better way to do this, and I assume that the second wasNull() test is redundant? Educate us, and Thanks

    Read the article

  • Is null a class in java?

    - by Somerandomeguy
    According to, http://www.freshvanilla.org:8080/display/www/Java+Interview+Questions Under, Which class is the superclass of every class? null seems to be the answer. I found that new Object().getClass().getSuperClass() verifies the answer as correct. But can null be considered a class? I see all primitive data types are represented as Class objects from java[dot]sun.com/j2se/1.4.2/docs/api/java/lang/Class.html

    Read the article

  • PHP ternary operator

    - by thecoshman
    ($DAO->get_num_rows() == 1) ? echo("is") : echo("are"); This dose not seem to be working for me,I get an error "Unexpected T_ECHO" I have tried it with out the brackets around the conditional. Am I just not able to use a ternary operator in this way? The $DAO-get_num_rows() returns an integer value. Thanks

    Read the article

  • C# Nested Property Accessing overloading OR Sequential Operator Overloading

    - by Tim
    Hey, I've been searching around for a solution to a tricky problem we're having with our code base. To start, our code resembles the following: class User { int id; int accountId; Account account { get { return Account.Get(accountId); } } } class Account { int accountId; OnlinePresence Presence { get { return OnlinePresence.Get(accountId); } } public static Account Get(int accountId) { // hits a database and gets back our object. } } class OnlinePresence { int accountId; bool isOnline; public static OnlinePresence Get(int accountId) { // hits a database and gets back our object. } } What we're often doing in our code is trying to access the account Presence of a user by doing var presence = user.Account.Presence; The problem with this is that this is actually making two requests to the database. One to get the Account object, and then one to get the Presence object. We could easily knock this down to one request if we did the following : var presence = UserPresence.Get(user.id); This works, but sort of requires developers to have an understanding of the UserPresence class/methods that would be nice to eliminate. I've thought of a couple of cool ways to be able to handle this problem, and was wondering if anyone knows if these are possible, if there are other ways of handling this, or if we just need to think more as we're coding and do the UserPresence.Get instead of using properties. Overload nested accessors. It would be cool if inside the User class I could write some sort of "extension" that would say "any time a User object's Account property's Presence object is being accessed, do this instead". Overload the . operator with knowledge of what comes after. If I could somehow overload the . operator only in situations where the object on the right is also being "dotted" it would be great. Both of these seem like things that could be handled at compile time, but perhaps I'm missing something (would reflection make this difficult?). Am I looking at things completely incorrectly? Is there a way of enforcing this that removes the burden from the user of the business logic? Thanks! Tim

    Read the article

  • Java operator precedence guidelines

    - by trashgod
    Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here are a number of resources on the topic: JLS Operators JLS Precedence Java Glossary Princeton Sun Tutorial University of West Florida Usenet discussion Additions or corrections welcome.

    Read the article

  • redefine __and__ operator

    - by wiso
    Why I can't redefine the __and__ operator? class Cut(object): def __init__(self, cut): self.cut = cut def __and__(self, other): return Cut("(" + self.cut + ") && (" + other.cut + ")") a = Cut("a>0") b = cut("b>0") c = a and b print c.cut() I want (a>0) && (b>0), but I got b, that the usual behaviour of and

    Read the article

  • Regex AND operator

    - by user366735
    Based on this answer http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator I tried the following on http://regexpal.com/ but was unable to get it to work. What am missing? Does javascript not support it? Regex: (?=foo)(?=baz) String: foo,bar,baz

    Read the article

  • subscript operator on pointers

    - by Lodle
    If i have a pointer to an object that has an overloaded subscript operator ( [] ) why cant i do this: MyClass *a = new MyClass(); a[1]; but have to do this instead: MyClass *a = new MyClass(); (*a)[1];

    Read the article

  • Using operator+ without leaking memory?

    - by xokmzxoo
    So the code in question is this: const String String::operator+ (const String& rhs) { String tmp; tmp.Set(this->mString); tmp.Append(rhs.mString); return tmp; } This of course places the String on the stack and it gets removed and returns garbage. And placing it on the heap would leak memory. So how should I do this?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >