dbAll() support distinct
This commit is contained in:
		
							parent
							
								
									aeaf3eb1dd
								
							
						
					
					
						commit
						1f14faf08c
					
				| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| namespace nulib\db; | ||||
| 
 | ||||
| use nulib\A; | ||||
| use nulib\cl; | ||||
| use nulib\php\func; | ||||
| use nulib\ValueException; | ||||
| @ -184,15 +185,19 @@ class Capacitor implements ITransactor { | ||||
| 
 | ||||
|   function dbAll(array $query, ?array $params=null): iterable { | ||||
|     $primaryKeys = $this->channel->getPrimaryKeys(); | ||||
|     $select = "select"; | ||||
|     if (A::pop($params, "distinct")) $select .= " distinct"; | ||||
|     return $this->storage->db()->all(cl::merge([ | ||||
|       "select", | ||||
|       $select, | ||||
|       "from" => $this->getTableName(), | ||||
|     ], $query), $params, $primaryKeys); | ||||
|   } | ||||
| 
 | ||||
|   function dbOne(array $query, ?array $params=null): ?array { | ||||
|     $select = "select"; | ||||
|     if (A::pop($params, "distinct")) $select .= " distinct"; | ||||
|     return $this->storage->db()->one(cl::merge([ | ||||
|       "select", | ||||
|       $select, | ||||
|       "from" => $this->getTableName(), | ||||
|     ], $query), $params); | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user