第一步:设置SET GLOBAL log_bin_trust_function_creators=TRUE;
如果报ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)这种错误
第二步:
$conditions = array('FIND_IN_SET(dept_id, getChildDept('.$dept_id.'))'); $condition_join = '`User`.`id` = `UserDepartment`.`user_id`'; if(!empty($c))$condition_join .= ' AND INSTR(User.pinyin,"'.$c.'")=2'; //分页 $this->paginate = array( 'UserDepartment' => array( 'conditions' => $conditions, 'order' => array('dept_id'=>'ASC'), 'limit' => 10, 'recursive' => -1, 'group' => array('user_id'), 'fields' => array('user_id','dept_id'), 'joins' => array(array( 'alias' => 'User', 'table' => 'zk_users', 'type' => 'INNER', 'conditions' => $condition_join, )), ) ); $data = $this->paginate('UserDepartment');