PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 1st, 2000, 04:02 PM
rah rah is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 1 rah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old July 4th, 2000, 09:34 AM
kaasgaard kaasgaard is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Aalborg, Denmark
Posts: 36 kaasgaard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to kaasgaard
Hi

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.

Regards

// Martin

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Passing args to class methods

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap