Yii Framework Forum: Select In Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Select In Yii Rate Topic: *---- 1 Votes

#1 User is offline   Aadhira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 06-February 13

  Posted 06 February 2013 - 03:59 AM

hi all ,i tried to get the result from the table MAIL using the below query ,but it gets displayed as a array ,how can i get it?
$connection=Yii::app()->db;
$sql = "SELECT Receiver from mail";
$command=$connection->createCommand($sql);
print_r($command->queryRow());
0

#2 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 780
  • Joined: 02-July 10
  • Location:Central Poland

Posted 06 February 2013 - 04:17 AM

use queryScalar() instead of queryRow()
red
0

#3 User is offline   Aadhira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 06-February 13

Posted 06 February 2013 - 04:43 AM

View Postredguy, on 06 February 2013 - 04:17 AM, said:

use queryScalar() instead of queryRow()




Thank you :)

One more help,if i select * from mail what can i use instead queryScalar?

$connection=Yii::app()->db;
$sql = "SELECT * from mail";
$command=$connection->createCommand($sql);
print_r($command->queryScalar());
0

#4 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 06 February 2013 - 05:15 AM

queryAll()
Posted Image
0

#5 User is offline   Aadhira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 06-February 13

Posted 07 February 2013 - 03:49 AM

View Postfouss, on 06 February 2013 - 05:15 AM, said:

queryAll()



<?php
echo'Only First Row'. "</br>";
echo '-----------'. "</br>";
$connection=Yii::app()->db;
$sql = "SELECT * from mail";
$command=$connection->createCommand($sql);
print_r($command->queryAll());
echo "</br>";?>
</p>


had tried this,but gets the result as

Array ( [0] => Array ( [E_Id] => xx@gmail.com [Receiver] => david) )


i need the values alone to be displayed,can u help????
0

#6 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 07 February 2013 - 04:29 AM

Try this my fiend!

echo'Only First Row'. "</br>";
echo '-----------'. "</br>";
$connection=Yii::app()->db;
$sql = "SELECT * from mail";
$command=$connection->createCommand($sql);
foreach ($command->queryAll()as $value) {
echo $value['E_id'].' '.$value['Receiver'].'</br>';
}


Posted Image
0

#7 User is offline   Aadhira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 06-February 13

Posted 07 February 2013 - 05:05 AM

View Postfouss, on 07 February 2013 - 04:29 AM, said:

Try this my fiend!

echo'Only First Row'. "</br>";
echo '-----------'. "</br>";
$connection=Yii::app()->db;
$sql = "SELECT * from mail";
$command=$connection->createCommand($sql);
foreach ($command->queryAll()as $value) {
echo $value['E_id'].' '.$value['Receiver'].'</br>';
}



Thanks a lot :D
0

#8 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 09 February 2013 - 07:29 AM

that's free! ;)
Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users