| 81 | + | :引数|null|string|array|TableIdentifier $table |
---|
| 82 | + | |
---|
| 83 | + | テーブル名を指定する |
---|
| 84 | + | ここで指定するとread onlyになり、fromから指定できなくなる |
---|
| 85 | + | |
---|
| 86 | + | ** from [#vHKbmez] |
---|
| 87 | + | :引数|string|array|TableIdentifier $table |
---|
| 88 | + | |
---|
| 89 | + | テーブル名を指定する |
---|
| 90 | + | コンストラクタで指定した場合、指定できない |
---|
| 91 | + | |
---|
| 92 | + | ** quantifier [#wh64NXe] |
---|
| 93 | + | :引数|string|Expression $quantifier DISTINCT|ALL |
---|
| 94 | + | |
---|
| 95 | + | DISTINCT属性を設定するか。 |
---|
| 96 | + | |
---|
| 97 | + | ** columns [#StzSgn0] |
---|
| 98 | + | :引数|array $columns |
---|
| 99 | + | |
---|
| 100 | + | selectするカラム名を指定する |
---|
| 101 | + | 連想配列の場合、''key値がエイリアス名''になる。 |
---|
| 102 | + | #sh(php){$select->columns(array("*"));} |
---|
| 103 | + | `test`.* |
---|
| 104 | + | #sh(php){$select->columns(array("id", "name", "value"));} |
---|
| 105 | + | `test`.`id` AS `id`, `test`.`name` AS `name`, `test`.`value` AS `value` |
---|
| 106 | + | #sh(php){$select->columns(array("id"=>"rev_id", "name"=>"rev_name", "value"=>"rev_value"));} |
---|
| 107 | + | `test`.`rev_id` AS `id`, `test`.`rev_name` AS `name`, `test`.`rev_value` AS `value` |
---|
| 108 | + | |
---|
| 109 | + | ** join [#slAKJ1d] |
---|
| 110 | + | :引数|string|array $name |
---|
| 111 | + | string $on |
---|
| 112 | + | string|array $columns |
---|
| 113 | + | string $type JOIN_*の中から一つ |
---|
| 114 | + | |
---|
| 115 | + | 結合設定 |
---|
| 116 | + | JOIN_INNER、JOIN_OUTER、JOIN_LEFT、JOIN_RIGHTの4種類が指定可能 |
---|
| 117 | + | #sh(php){$select->join("test2", "test.id = test2.id", Zend\Db\Sql\Select::SQL_STAR, Zend\Db\Sql\Select::JOIN_LEFT);} |
---|
| 118 | + | `test2`.* FROM `test` LEFT JOIN `test2` ON `test`.`id` = `test2`.`id` |
---|
| 119 | + | #sh(php){$select->join("test2", "test.id = test2.id", array("id", "name", "age"), Zend\Db\Sql\Select::JOIN_LEFT);} |
---|
| 120 | + | `test2`.`id` AS `id`, `test2`.`name` AS `name`, `test2`.`age` AS `age` FROM `test` LEFT JOIN `test2` ON `test`.`id` = `test2`.`id` |
---|
| 121 | + | |
---|
| 122 | + | ** where [#LrEKQK5] |
---|
| 123 | + | :引数|Where|\Closure|string|array|Predicate\PredicateInterface $predicate |
---|
| 124 | + | string $combination Predicate\PredicateSetで定義されている OP_* の中から一つ |
---|
| 125 | + | |
---|
| 126 | + | Where句を設定 |
---|
| 127 | + | #sh(php){$select->where(array("id"=>1, "name"=>"yamada"));} |
---|
| 128 | + | WHERE `id` = '1' AND `name` = 'yamada' |
---|
| 129 | + | #sh(php){$select->where(array("id"=>1, "name"=>"yamada"), Zend\Db\Sql\Predicate\PredicateSet::OP_OR);} |
---|
| 130 | + | WHERE `id` = '1' OR `name` = 'yamada' |
---|
| 131 | + | Predicate\PredicateInterface |
---|
| 132 | + | #sh(php){{ |
---|
| 133 | + | $nest = $select->where->nest(); |
---|
| 134 | + | $nest->equalTo("name", "yamada"); |
---|
| 135 | + | $nest->OR->equalTo("age", "20"); |
---|
| 136 | + | $nest->unnest(); |
---|
| 137 | + | }} |
---|
| 138 | + | WHERE (`name` = 'yamada' OR `age` = '20') |
---|
| 139 | + | #sh(php){{ |
---|
| 140 | + | $nest = $select->where->nest(); |
---|
| 141 | + | $nest2_1 = $nest->nest(); |
---|
| 142 | + | $nest2_1->equalTo("name", "yamada"); |
---|
| 143 | + | $nest2_1->OR->equalTo("name", "tanaka"); |
---|
| 144 | + | $nest2_1->unnest(); |
---|
| 145 | + | $nest2_2 = $nest->AND->nest(); |
---|
| 146 | + | $nest2_2->equalTo("age", "10"); |
---|
| 147 | + | $nest2_2->OR->equalTo("age", "20"); |
---|
| 148 | + | $nest2_2->unnest(); |
---|
| 149 | + | $nest->unnest(); |
---|
| 150 | + | }} |
---|
| 151 | + | WHERE ((`name` = 'yamada' OR `name` = 'tanaka') AND (`age` = '10' OR `age` = '20')) |
---|
| 152 | + | #sh(php){$select->where->NEST->equalTo("name", "yamada")->OR->equalTo("age", "20")->UNNEST;} |
---|
| 153 | + | WHERE (`name` = 'yamada' OR `age` = '20') |
---|
| 154 | + | #sh(php){{ |
---|
| 155 | + | $select->where->NEST |
---|
| 156 | + | ->NEST |
---|
| 157 | + | ->equalTo("name", "yamada") |
---|
| 158 | + | ->OR->equalTo("name", "tanaka") |
---|
| 159 | + | ->UNNEST |
---|
| 160 | + | ->AND->NEST |
---|
| 161 | + | ->equalTo("age", "10") |
---|
| 162 | + | ->OR->equalTo("age", "20") |
---|
| 163 | + | ->UNNEST |
---|
| 164 | + | ->UNNEST; |
---|
| 165 | + | }} |
---|
| 166 | + | WHERE ((`name` = 'yamada' OR `name` = 'tanaka') AND (`age` = '10' OR `age` = '20')) |
---|
| 167 | + | ** group [#8OTtXtP] |
---|
| 168 | + | :|引数|string|array |
---|
| 169 | + | |
---|
| 170 | + | グループ設定 |
---|
| 171 | + | #sh(php){$select->group("name");} |
---|
| 172 | + | GROUP BY `name` |
---|
| 173 | + | |
---|
| 174 | + | ** having [#aDnoqCD] |
---|
| 175 | + | :引数|Where|\Closure|string|array $predicate |
---|
| 176 | + | string $combination One of the OP_* constants from Predicate\PredicateSet |
---|
| 177 | + | |
---|
| 178 | + | #sh(php){$select->having(array("age"=>10, "weight"=>20));} |
---|
| 179 | + | HAVING `age` = '10' AND `weight` = '20' |
---|
| 180 | + | |
---|
| 181 | + | ** order [#LBspsa8] |
---|
| 182 | + | :引数|string|array $order |
---|
| 183 | + | |
---|
| 184 | + | オーダー設定 |
---|
| 185 | + | #sh(php){$select->order("name DESC");} |
---|
| 186 | + | ORDER BY `name` DESC |
---|
| 187 | + | #sh(php){$select->order("name ASC");} |
---|
| 188 | + | ORDER BY `name` ASC |
---|
| 189 | + | |
---|
| 190 | + | ** limit [#jolzJvg] |
---|
| 191 | + | :引数|int $limit |
---|
| 192 | + | |
---|
| 193 | + | Limit設定 |
---|
| 194 | + | #sh(php){$select->limit(1);} |
---|
| 195 | + | LIMIT 1 |
---|
| 196 | + | |
---|
| 197 | + | ** offset [#zD1URqW] |
---|
| 198 | + | :引数|int $offset |
---|
| 199 | + | |
---|
| 200 | + | Offset設定 |
---|
| 201 | + | #sh(php){$select->offset(3);} |
---|
| 202 | + | OFFSET 3 |
---|
| 203 | + | ** combine [#OlWRQfW] |
---|
| 204 | + | :引数|Select $select |
---|
| 205 | + | string $type |
---|
| 206 | + | string $modifier |
---|