symfony
symfony forum
Home » support » General discussion » [resolved] doSelectRS problem
[resolved] doSelectRS problem [message #9234] Sun, 23 July 2006 18:11 Go to next message
seb.b  is currently offline seb.b
Messages: 37
Registered: July 2006
Member
Hello,
I've got a problem with the doSelectRS function, I never go in the while instruction. However, when I execute the request in phpmyadmin (I take the request in the log file) I've some results.
I don't see what is not good in my code...

$c=new Criteria();
$c->add(DepartementPeer::ID_REGION,'54');
$c->clearSelectColumns();
$c->addSelectColumn(DepartementPeer::ID_DEPARTEMENT);
$c->addSelectColumn(DepartementPeer::DEP_NOM);;
$rs = DepartementPeer::doSelectRS($c);
$liste = "";
while ($rs->next) {
sfContext::getInstance()->getLogger()->info("boucle");
$liste =$liste."<option value=\"".$rs->getString(1)."\">".$rs->getString(2)."</option >";
}

Any idea?
Thx

[Updated on: Mon, 24 July 2006 14:35] by Moderator

Re: doSelectRS problem [message #9235 is a reply to message #9234 ] Sun, 23 July 2006 21:34 Go to previous messageGo to next message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
I don't really know why doSelectRS doesn't work but... why don't you use doSelect instead? And why do you manually build the option list? You are blending the model layer (the database) and the view layer (the html code).

I advise you to read and use the form helpers of symfony, especially the options_for_select function: http://www.symfony-project.com/content/book/page/templating_ form_helpers.html

Other piece of advice: follow the MVC guidelines. It doesn't really make sense to use symfony outside the MVC paradigm...

Now if you still want to debug the doSelectRS problem, look at the log file and spot the sql query that propel constructs. That should help you to figure out what went wrong. Feel free to post the sql query here if you have no clue.

Cheers!
Re: doSelectRS problem [message #9236 is a reply to message #9235 ] Sun, 23 July 2006 23:03 Go to previous messageGo to next message
seb.b  is currently offline seb.b
Messages: 37
Registered: July 2006
Member
I've beginning using a doSelect and the following code to initialize a select tag (after an ajax call)
<?php
foreach($departement as $work)
echo "<option value=".$work->getIdDepartement().">".$work->getDepNom(). "</option>";
?>

But the problem is that this method take too long time, and after 60 seconds (time out), the list is initialized but not with all the data that I should have got (600 records).

So I used doSelectRS to see if it was better.

The SQL generate with doSelectRS is good, and when I execute it under phpmyadmin, I can see the results I want.

Re: doSelectRS problem [message #9257 is a reply to message #9236 ] Mon, 24 July 2006 13:32 Go to previous messageGo to next message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
The code you wrote above is incorrect. You should have
while ($rs->next())


Then i suggest you to take a look at the form helper documentation and especially options_for_select, those functions are really here to help you... Smile

[Updated on: Mon, 24 July 2006 13:33]

Re: doSelectRS problem [message #9293 is a reply to message #9257 ] Mon, 24 July 2006 19:37 Go to previous messageGo to next message
seb.b  is currently offline seb.b
Messages: 37
Registered: July 2006
Member
What stupid mistake I make... Sorry for my question.

To answer to your suggestion, this is the reason I use doSelectRS:
When I used the doSelectRS and I build the <option> list in my while loop this take a few time.
But when I used the doSelect and I build the <option> list in the view (MVC) with this code :
<?php
foreach($departement as $work)
echo "<option value=".$work->getIdDepartement().">".$work->getDepNom(). "</option>";
?>
,this take a long time (more than 60sec).

If you know why, I'm ready to change my code, because it's true it's not very pretty.

Thx
Re: doSelectRS problem [message #9294 is a reply to message #9293 ] Mon, 24 July 2006 19:55 Go to previous message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
I think that it is perfectly all right to use doSelectRS instead of doSelect. It is even recommended in the propel doc in case of big result sets, as seems to be your case.

However i think that you should use options_for_select to build your menu since the use of html code is in principle restricted to templates and helpers.
Previous Topic:[resolved] Form fillin
Next Topic:Pooky - Usage of sfMemcacheCache.class.php
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software