1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Rep Power
    This in PHP3:

    I have a class 'sm' that wants to call a method in another class 'db'.

    Class sm has a class variable $db that holds an instance of db.

    This works:

    $result = $this->db->Query("SELECT * FROM tablename WHERE somefield = 'xyz'");

    This does not work:

    $sql = "SELECT * FROM tablename WHERE somefield = 'xyz'";

    $result = $this->db->Query($sql);

    The second version causes PostGres to issue a parsing error. I've cut and pasted the SQL back and forth... it's identical in both cases.

    Printing the $sql arg in the receiving method shows exactly the same text either way.

    Setting a local variable in the receiving method to the passsed $sql, and then passing the local to PostGres doesn't help.

    Passing $sql by reference doesn't help.

    I'm baffled. Any ideas?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Aalborg, Denmark
    Rep Power

    Sounds like a prob i once had. Try
    $result = $this->db->Query("sql");

    It sounds dumb, i know, but it solved my prob. I think it has to do with the way strings are parsed in the db functions.


    // Martin

    [This message has been edited by kaasgaard (edited July 04, 2000).]

Similar Threads

  1. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  2. Dynamically include methods in a class - How
    By spybreak in forum PHP Development
    Replies: 7
    Last Post: December 10th, 2003, 09:04 PM
  3. Learning Mouse Event Handling.
    By coredumped in forum Java Help
    Replies: 5
    Last Post: December 4th, 2003, 08:44 AM
  4. class 1 functions used in class 2
    By ioScream in forum PHP Development
    Replies: 4
    Last Post: October 30th, 2003, 03:15 PM
  5. virtual base class inheritance question
    By Rooster in forum C Programming
    Replies: 3
    Last Post: October 18th, 2003, 09:08 AM

IMN logo majestic logo threadwatch logo seochat tools logo