Search the Community
Showing results for tags 'sort'.
-
First I just want to thank Larry for explaining PHP in a method I could understand. From reading his book in three days I went from a barely functioning site with security holes to a improved, stable site. If your interested in seeing it, its here, http://medieval.name I did have one issue, that is with using a sort feature. I use the template from Chapter 10. Setting the sort variable, setting up the switch, adding $order_by to the query, adding sort to the pagination. The sort works, but it sorts all data, not limiting itself to the data from the query. Im sure Im missing something o
- 7 replies
-
- chapter 10
- sort
-
(and 2 more)
Tagged with:
-
Hello, I'm working in Yii framework. In my index action I created the dataprovider in the following way $connection=Yii::app()->db; $user_id = Yii::app()->user->id; $sql = 'SELECT * FROM post LEFT JOIN comment ON post.id = comment.post_id AND comment.user_id =:user_id LIMIT 0 , 30 '; $command=$connection->createCommand($sql); $command->bindParam(':user_id', $user_id,PDO::PARAM_STR); $rawData = $command->execute(); $dataProvider=new CArrayDataProvider($rawData, array( 'id'=>'user', 'sort'=&
-
Hi, I've modified script 10.5 by adding a search form at the top. The search correctly returns a paginated table of results with page numbers and a next link. However, there are some problems that is beyond my knowledge of php. The first is that I don't know how to prevent the undefined index error caused by the blank form fields when the next link or a page number link is clicked. In other words, trying to view the paged results creates an undefined index error. The second thing is that clicking the sort link returns all the database records, not just the search results. The code is
-
Hmm, I must say it is a bit disappointing to see entire "virtual attribute" concept mostly misleading. Well, I have this inside my 'Users' model: public $fullname; {other code here - not really important} public function search() { $sort = new CSort(); $sort->attributes = array('*', 'CONCAT(surname, ", ", forename) AS fullname'); $sort->defaultOrder = array('fullname' => CSort::SORT_ASC); $criteria=new CDbCriteria; $criteria->select = array('*', 'CONCAT(surname, ", ", forename) AS fullname'); $criteria->compare('id', $this->id); $criteria->compa