Get distinct record from table using zend functions?

狂风中的少年 提交于 2020-01-07 05:37:12

问题


I am getting all records like this in Zend:

$table = new Model_Student_Object();
$select = $table->select();
echo $select->assemble();die();

Result of above code is following query:

SELECT `student`.* FROM `student`

Now I want to get distinct records by Zip code. So query should be:

SELECT DISTINCT `student`.zip FROM `student` WHERE `student`.zip != '' 

How will I right above query with zend functions ??

Thanks


回答1:


Try this

    $db = Zend_Db::factory( ...options... );
    $select = new Zend_Db_Select($db);
$select= $db->select()->distinct()->from('s'=>'student'),'zip')->where('practiceID in("1") and s.zip!='')


来源:https://stackoverflow.com/questions/6110284/get-distinct-record-from-table-using-zend-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!