List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:January 12 2002 1:41am
Subject:Re: Inserting Object property in MySQL
View as plain text  
THis is more of a PHP issue, but:

When PHP evaluates variables in a double-quoted string, it sees your $this 
(the object reference) and immediately evaluates it (just returning its 
type - Object). If you want to tell PHP to dereference $this->PNPSES->ses 
properly, do

         $query = "INSERT INTO 
table1(created,updated,ses)     values(now(),now(),'".$this->PNPSES->ses."')";
or
         $query = "INSERT INTO 
table1(created,updated,ses)     values(now(),now(),'{$this->PNPSES->ses}')";

The later method should work, according to the docs, but I haven't tried 
it. For more info, see:

         http://www.php.net/manual/en/language.types.string.php
and
         http://www.php.net/manual/en/language.types.string.php#language.typ 
http://www.php.net/manual/en/language.types.string.php#language.types.string 
.parsing


-steve


At 05:19 PM 1/11/02 , PinkeshP@stripped wrote:
>I've got the following query executing in my php code:
>
>$query = "INSERT INTO 
>table1(created,updated,ses)     values(now(),now(),'$this->PNPSES->ses')";
>MYSQL_QUERY($query);
>
>query executes fine, but when I look at the ses column in inserted row it 
>says Object->ses instead of a value.
>
>Any ideas why?



+------------------------------------------------------------------------+
| Steve Edberg                                      sbedberg@stripped |
| Database/Programming/SysAdmin                            (530)754-9127 |
| University of California, Davis             http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

Thread
Inserting Object property in MySQLPinkeshP12 Jan
Re: Inserting Object property in MySQLSteve Edberg12 Jan