質問編集履歴

2

追加

2016/09/20 08:11

投稿

amaguri
amaguri

スコア227

test CHANGED
File without changes
test CHANGED
@@ -32,24 +32,10 @@
32
32
 
33
33
  ```
34
34
 
35
- これを綺麗にまとめようと思い
35
+ これを綺麗にまとめたく思い
36
36
 
37
- ```ここ言語を入力
37
+ find()を一度だけにしたく
38
38
 
39
- $ips=CommonComponent::GetAllowIPsByAccessIp();
39
+ 条件を$conditionsで条件分岐しようと思うのですが一度使用してしまっています。
40
40
 
41
- if(empty($ips)){
42
-
43
- $conditions=array('conditions' => array('Runhists.username' => $conditions,'Runhists.private_flg' => 0),'order' => 'created desc', 'limit'=>100);
44
-
45
- } else {
46
-
47
- $conditions=array('conditions' => $conditions, 'order' => 'created desc','limit'=>100);
48
-
49
- }
50
-
51
- $querys=$this->Runhists->find('all',$conditions);
52
-
53
- ```
54
-
55
- と書いのですがうまく処理されません何が原因でしょうか?
41
+ どうしうまく綺麗にまとめられまでしょうか?

1

追加

2016/09/20 08:11

投稿

amaguri
amaguri

スコア227

test CHANGED
File without changes
test CHANGED
@@ -1,10 +1,28 @@
1
1
  ```ここに言語を入力
2
+
3
+ if ( $u_out == "history" ){
4
+
5
+ $conditions=array();
6
+
7
+ if ( $u_userid != "" ){
8
+
9
+ $conditions=array('username' => $u_userid);
10
+
11
+ }
2
12
 
3
13
  $ips=CommonComponent::GetAllowIPsByAccessIp();
4
14
 
5
15
  if(empty($ips)){
6
16
 
17
+ $querys = $this->Runhists->find('all', array(
18
+
19
+ 'conditions' => array(
20
+
21
+ 'Runhists.username' => $conditions,
22
+
23
+ 'Runhists.private_flg' => 0),
24
+
7
- $querys = $this->Runhists->find('all', array('conditions' => array('Runhists.username' => $conditions,'Runhists.private_flg' => 0),'order' => 'created desc', 'limit'=>100));
25
+ 'order' => 'created desc', 'limit'=>100));
8
26
 
9
27
  } else {
10
28