Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2007, 03:55 AM
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default Zend_Db_table , DISTINCT

Hi,
How to make a DISTINCT selection from a table?
from table below, I select all data from table ITEM, in table item, there are some records which have same name.

PHP Code:
$myItem = new Item();
$view->item $myItem->fetchAll(); 
can I use something like:
PHP Code:
$view->item $myItem->fetchAll('DISTINCT'); 
?

I can use DISTINCT mode when I use the DB object instead of Table object, like:

PHP Code:
$sql "SELECT `itemid` DISTINCT FROM `item`";
$view->item $db->query($sql); 
But, if I use the DB object, what's the point in creating model of table ITEM ?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-05-2007, 07:40 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 101
Default

What adapter are you using ? PDO_Mysql ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2007, 07:44 AM
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default

Yes, I use PDO_MySQL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-13-2007, 02:47 PM
Junior Member
 
Join Date: Sep 2007
Posts: 1
Default No Distinct Select with DB Table

I am also trying to get Zend Db Table to execute a Distinct Select. Dosent appear like that is currently an option.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-01-2007, 01:46 PM
Junior Member
 
Join Date: Aug 2007
Posts: 1
Default

I'm trying the same thing. Their doesn't appear to be an option for this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-01-2007, 11:09 PM
Junior Member
 
Join Date: Oct 2007
Posts: 5
Default

From the documentation:

Quote:
10.4.3.10. Adding the DISTINCT Query Modifier

The distinct() method enables you to add the DISTINCT keyword to your SQL query.

Example 10.63. Example of the distinct() method


<?php

// Build this query:
// SELECT DISTINCT p."product_name"
// FROM "products" AS p

$select = $db->select()
->distinct()
->from(array('p' => 'products'), 'product_name');


10.4.3.11. Adding the FOR UPDATE Query Modifier

The forUpdate() method enables you to add the FOR UPDATE modifier to your SQL query
Zend Framework: Documentation

Doesn't seem like you can execute it from a model though...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:17 PM.