[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-08 Thread Jill Elaine

Thank you very much for your explanation. This thread has been very
helpful and has improved my understanding.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-07 Thread Eno

On Sun, 6 Apr 2008, Jill Elaine wrote:

> On Apr 6, 2:19 am, "Thomas Rabaix" <[EMAIL PROTECTED]> wrote:
> > Does the getFilepath return a string value, or just echo the value ...
> > that will explain why the filepath is displayed at first
> 
> I am not sure I understand the difference?

Simply put, you can only chain function calls like that if your functions 
return objects.

$this->function() means call the function() method of the current 
object...



-- 



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-07 Thread Jill Elaine

On Apr 6, 2:15 pm, "Thomas Rabaix" <[EMAIL PROTECTED]> wrote:
> Don't use RAW SQL with mysql_* function. It is not the aims of this framework.

You are absolutely right, Thomas. I am struggling with Propel right
now. Thanks to your link, I found quite a bit of documentation on
propel and will print it. It is like learning a foreign language to
me, and so, I still have to translate from first language, SQL, to
propel. It will be some time before I can think in propel!

Because my time frame is tight, I have given up on propel in a few
places until I become more proficient. I have lots of other code that
will need to be refactored, so I've made notes on where the 'uglies'
are hiding and will come back to change to propel. I am a believer in
database abstraction layer!

I have learned much from this thread! Thank you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Thomas Rabaix

Don't use RAW SQL with mysql_* function. It is not the aims of this framework.

You can do :

[...]
$file = FilePeer::doSelectOne($c);

if($file instanceof File) {
 return $file->getFilePath();
}

return null
[...]


If you use doSelectOne, you don't have to call setLimit ...
if you use doSelectRs, this return a collection of ResultSet, to get
the first entry, use $rs->next()
if you use doSelect, this return an array of File

You sould read the propel documentation. And if you are at the point
to write raw SQL, read this
http://propel.phpdb.org/docs/en/user_guide/chapters/FindingObjects.html#WritingSQL
.

Thomas

On Sun, Apr 6, 2008 at 10:33 PM, Jill Elaine <[EMAIL PROTECTED]> wrote:
>
>  I realized I was making my selection criteria much more complicated
>  than I need. I wrote the function with sql and can see more clearly my
>  criteria:
> public function getFilePath()
> {
> $fileid = $this->getFileId();
> mysql_connect("localhost","myuser","mypassword");
> mysql_select_db("mydb");
> $getfilepath = "SELECT file_path FROM file WHERE file.id = 
> $fileid";
> $run = mysql_query($getfilepath);
> $row = mysql_fetch_assoc($run);
> $filepath = $row['file_path'];
> return $filepath;
> mysql_close();
> }
>  This works well, and I can use return instead of echo. Okay, this
>  propel language is so foreign to me! I'll keep learning and rewrite my
>  sql statements someday...when I get smarter!
>
>
>
>
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Jill Elaine

I realized I was making my selection criteria much more complicated
than I need. I wrote the function with sql and can see more clearly my
criteria:
public function getFilePath()
{
$fileid = $this->getFileId();
mysql_connect("localhost","myuser","mypassword");
mysql_select_db("mydb");
$getfilepath = "SELECT file_path FROM file WHERE file.id = 
$fileid";
$run = mysql_query($getfilepath);
$row = mysql_fetch_assoc($run);
$filepath = $row['file_path'];
return $filepath;
mysql_close();
}
This works well, and I can use return instead of echo. Okay, this
propel language is so foreign to me! I'll keep learning and rewrite my
sql statements someday...when I get smarter!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Jill Elaine

> If there is only one filepath, add $c->setLimit(1) to get only one
> path.
The file_id and course_session_id are a combination primary key for
the FileToSession table, so there is only one.
>
> and just return $resultset->getString(1);
I tried:
 public function getFilePath()
{
$sessionid = sfContext::getInstance()->getUser()-
>getAttribute('sessionid');

$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(FilePeer::FILE_PATH);
$c->addJoin( FileToSessionPeer::FILE_ID,
FilePeer::ID);
$c->add(FileToSessionPeer::FILE_ID, $this-
>getFileId());
$c->addAnd(FileToSessionPeer::COURSE_SESSION_ID,
$sessionid);
$c->setLimit(1);

$resultset = FilePeer::doSelectRS($c);
return $resultset->getString(1);
 }
But this throws error: "invalid resultset column: 1"
This is related to:
http://trac.symfony-project.com/browser/trunk/lib/vendor/creole/drivers/mysql/MySQLResultSet.php?rev=1723
public function getString($column)
107 {
108 $idx = (is_int($column) ? $column - 1 : $column);
109 if (!array_key_exists($idx, $this->fields)) { throw new
SQLException("Invalid resultset column: " . $column); }
110 if ($this->fields[$idx] === null) { return null; }
111 return (string) $this->fields[$idx];
112 }

I think because resultset is an array of keys and values and I'm not
returning it right???

I also tried:
...
$c->addAnd(FileToSessionPeer::COURSE_SESSION_ID,
$sessionid);
$c->setLimit(1);

$resultset = FilePeer::doSelectOne($c);
return $resultset->getString(1);
 }
But then I get "wrapped: invalid resultset column: 2"

> You have to test that the result is not null.
The file_path is a required field in the File table, so it's not null,
but I understand the wisdom of testing for null anyway.

I do appreciate your advice and help, Thomas. Thank you.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Thomas Rabaix

Hello,

It look like your code get X filepath and echo all the different path.
If there is only one filepath, add $c->setLimit(1) to get only one
path.

and just return $resultset->getString(1);

You have to test that the result is not null.

Thomas

On Sun, Apr 6, 2008 at 4:23 PM, Jill Elaine <[EMAIL PROTECTED]> wrote:
>
>  I tried putting a return instead of an echo in the code below, but it
>  doesn't work. I end up with only the filename in the a href, and no
>  filepath.
>
> >   foreach ($filepath as  $value)
>  >   {
>  >   echo $value;
>  >   }
>
>  Thanks to the help I received here, I have something that works, and
>  best yet, I have learned something about echo and return: I have more
>  to learn in this area, and I like learning!
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Jill Elaine

I tried putting a return instead of an echo in the code below, but it
doesn't work. I end up with only the filename in the a href, and no
filepath.
>   foreach ($filepath as  $value)
>   {
>   echo $value;
>   }

Thanks to the help I received here, I have something that works, and
best yet, I have learned something about echo and return: I have more
to learn in this area, and I like learning!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Jill Elaine

On Apr 6, 2:19 am, "Thomas Rabaix" <[EMAIL PROTECTED]> wrote:
> Does the getFilepath return a string value, or just echo the value ...
> that will explain why the filepath is displayed at first

I am not sure I understand the difference? H, time for some
investigation...

Okay, I see what you mean, Thomas. In my lib/FileToSession.php, I have
this simple get:
public function getFileName()
{
return $this->getFile()->getFileName();
}
but for the filepath, it is very clumsily built as I am not so good
with propel:
public function getFilePath()
{
$sessionid = sfContext::getInstance()->getUser()-
>getAttribute('sessionid');
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(FilePeer::FILE_PATH);
$c->addJoin( FileToSessionPeer::FILE_ID, FilePeer::ID);
$c->add(FileToSessionPeer::FILE_ID, $this->getFileId());
$c->addAnd(FileToSessionPeer::COURSE_SESSION_ID, $sessionid);

$resultset = FilePeer::doSelectRS($c);
$filepath = array();

 while($resultset->next())
 {
 $filepath[] = $resultset->getString(1);
 }

  foreach ($filepath as  $value)
  {
  echo $value;
  }

}
and you can see that it does indeed ECHO a value as opposed to return
it! Well, I could experiment with changing echo to return? I really
struggled to get the filepath selection to work at all. FileToSession
is a many-to-many through table to the File table: my nemesis! And I
couldn't figure out how to pass the sessionid to the function other
than through a user attribute var. Heh, a look in my messy closet!
I'll try 'return' in this function and see if it makes a difference.
And I'll listen carefully to any advice about better ways to build the
above clumsy filepath function!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-06 Thread Thomas Rabaix

Does the getFilepath return a string value, or just echo the value ...
that will explain why the filepath is displayed at first

Thomas

On Sun, Apr 6, 2008 at 6:53 AM, Jill Elaine <[EMAIL PROTECTED]> wrote:
>
>  Coolio! Yes! Your suggestion works!
>
>  First of all, I realized I didn't need to put 'http://mysite.com' at
>  the beginning: as long as my filepath starts with a slash, the site
>  name will be added to the front of the URL.
>  So that made my task a bit more simple.
>
>
>  > Did you try putting parentheses around the function calls?
>  I tried and it works!
>
>  Now I have Download File
>  and this works just great!
>
> >
>  > Or assign the value of each "get" to a temporary variable before using
>  > those in the concatenation expression?
>  I did try
>  $filepath = $file->getFilepath();
>  $filename = $file->getFilename();
>  Download File doesn't
>  work
>  Download File
>  doesn't work either! I am still mystified but happy to have a
>  solution! Thank you!
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-05 Thread Jill Elaine

Coolio! Yes! Your suggestion works!

First of all, I realized I didn't need to put 'http://mysite.com' at
the beginning: as long as my filepath starts with a slash, the site
name will be added to the front of the URL.
So that made my task a bit more simple.

> Did you try putting parentheses around the function calls?
I tried and it works!

Now I have Download File
and this works just great!
>
> Or assign the value of each "get" to a temporary variable before using
> those in the concatenation expression?
I did try
$filepath = $file->getFilepath();
$filename = $file->getFilename();
Download File doesn't
work
Download File
doesn't work either! I am still mystified but happy to have a
solution! Thank you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Mysterious URL concatenation behavior

2008-04-05 Thread Eno

On Apr 5, 8:57 pm, Jill Elaine <[EMAIL PROTECTED]> wrote:

> I want to provide a link to download a file. There are two values that
> The values display just fine one at a time:
> echo $file->getFilepath();
> prints /this/correct/path/
>
> echo $file->getFilename();
> prints thisfile.pdf
>
> That all looks good! But when I try to make one long URL out of
> them...
> $full_path_to_file = 
> 'http://mysite.com'.$file->getFilepath().$file->getFilename();
>
> echo $full_path_to_file
> prints /this/correct/path/http://mysite.comthisfile.pdf
> BUT it should behttp://mysite.com/this/correct/path/thisfile.pdf


Did you try putting parentheses around the function calls?

Or assign the value of each "get" to a temporary variable before using
those in the concatenation expression?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---