Skip to content

Commit fa8e994

Browse files
committed
Some tweaks from the last merge
1 parent be31f1e commit fa8e994

File tree

5 files changed

+78
-42
lines changed

5 files changed

+78
-42
lines changed

src/DatabaseQuery.php

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,10 @@ public function currentTimestamp()
656656

657657
/**
658658
* Add to the current date and time.
659+
*
659660
* Usage:
660661
* $query->select($query->dateAdd());
662+
*
661663
* Prefixing the interval with a - (negative sign) will cause subtraction to be used.
662664
* Note: Not all drivers support all units.
663665
*
@@ -807,7 +809,7 @@ public function exec($columns)
807809
* @param string $value The value to search for.
808810
* @param string $set The set of values.
809811
*
810-
* @return string Returns the find_in_set() MySQL function and must be translated in each driver.
812+
* @return string A representation of the MySQL find_in_set() function for the driver.
811813
*
812814
* @since __DEPLOY_VERSION__
813815
*/
@@ -1264,6 +1266,38 @@ public function quoteName($name, $as = null)
12641266
return $this->db->quoteName($name, $as);
12651267
}
12661268

1269+
/**
1270+
* Get the function to return a random floating-point value
1271+
*
1272+
* Usage:
1273+
* $query->rand();
1274+
*
1275+
* @return string
1276+
*
1277+
* @since __DEPLOY_VERSION__
1278+
*/
1279+
public function rand()
1280+
{
1281+
return '';
1282+
}
1283+
1284+
/**
1285+
* Get the regular expression operator
1286+
*
1287+
* Usage:
1288+
* $query->where('field ' . $query->regexp($search));
1289+
*
1290+
* @param string $value The regex pattern.
1291+
*
1292+
* @return string
1293+
*
1294+
* @since __DEPLOY_VERSION__
1295+
*/
1296+
public function regexp($value)
1297+
{
1298+
return ' ' . $value;
1299+
}
1300+
12671301
/**
12681302
* Add a RIGHT JOIN clause to the query.
12691303
*
@@ -1592,14 +1626,13 @@ public function union($query, $distinct = false, $glue = '')
15921626
* $query->union('SELECT name FROM #__foo')
15931627
* $query->union(array('SELECT name FROM #__foo','SELECT name FROM #__bar'))
15941628
*
1595-
* @param mixed $query The JDatabaseQuery object or string to union.
1596-
* @param boolean $distinct Not used - ignored.
1597-
* @param string $glue Not used - ignored.
1629+
* @param DatabaseQuery|string $query The DatabaseQuery object or string to union.
1630+
* @param boolean $distinct Not used - ignored.
1631+
* @param string $glue The glue by which to join the conditions.
15981632
*
1599-
* @return Query\QueryElement Returns this object to allow chaining.
1633+
* @return DatabaseQuery Returns this object to allow chaining.
16001634
*
16011635
* @see union
1602-
*
16031636
* @since __DEPLOY_VERSION__
16041637
*/
16051638
public function unionAll($query, $distinct = false, $glue = '')

src/Mysql/MysqlQuery.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ public function concatenate($values, $separator = null)
193193
}
194194
}
195195

196+
/**
197+
* Get the function to return a random floating-point value
198+
*
199+
* Usage:
200+
* $query->rand();
201+
*
202+
* @return string
203+
*
204+
* @since __DEPLOY_VERSION__
205+
*/
206+
public function rand()
207+
{
208+
return ' RANDOM() ';
209+
}
210+
196211
/**
197212
* Sets the offset and limit for the result set, if the database driver supports it.
198213
*

src/Mysqli/MysqliQuery.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,14 @@ public function setLimit($limit = 0, $offset = 0)
213213
}
214214

215215
/**
216-
* Return correct regexp operator for mysqli.
217-
*
218-
* Ensure that the regexp operator is mysqli compatible.
216+
* Get the regular expression operator
219217
*
220218
* Usage:
221219
* $query->where('field ' . $query->regexp($search));
222220
*
223221
* @param string $value The regex pattern.
224222
*
225-
* @return string Returns the regex operator.
223+
* @return string
226224
*
227225
* @since __DEPLOY_VERSION__
228226
*/
@@ -232,18 +230,16 @@ public function regexp($value)
232230
}
233231

234232
/**
235-
* Return correct rand() function for Mysqli.
233+
* Get the function to return a random floating-point value
236234
*
237-
* Ensure that the rand() function is Mysqli compatible.
238-
*
239235
* Usage:
240-
* $query->Rand();
241-
*
242-
* @return string The correct rand function.
236+
* $query->rand();
237+
*
238+
* @return string
243239
*
244240
* @since __DEPLOY_VERSION__
245241
*/
246-
public function Rand()
242+
public function rand()
247243
{
248244
return ' RAND() ';
249245
}
@@ -257,10 +253,9 @@ public function Rand()
257253
* $query->findInSet((int) $parent->id, 'a.assigned_cat_ids')
258254
*
259255
* @param string $value The value to search for.
260-
*
261256
* @param string $set The set of values.
262257
*
263-
* @return string Returns the find_in_set() Mysql translation.
258+
* @return string A representation of the MySQL find_in_set() function for the driver.
264259
*
265260
* @since __DEPLOY_VERSION__
266261
*/

src/Postgresql/PostgresqlQuery.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,11 @@ public function processLimit($query, $limit, $offset = 0)
697697
}
698698

699699
/**
700-
* Add to the current date and time in Postgresql.
700+
* Add to the current date and time.
701+
*
701702
* Usage:
702703
* $query->select($query->dateAdd());
704+
*
703705
* Prefixing the interval with a - (negative sign) will cause subtraction to be used.
704706
*
705707
* @param datetime $date The date to add to
@@ -709,7 +711,6 @@ public function processLimit($query, $limit, $offset = 0)
709711
* @return string The string with the appropriate sql for addition of dates
710712
*
711713
* @since __DEPLOY_VERSION__
712-
* @note Not all drivers support all units. Check appropriate references
713714
* @link http://www.postgresql.org/docs/9.0/static/functions-datetime.html.
714715
*/
715716
public function dateAdd($date, $interval, $datePart)
@@ -725,16 +726,14 @@ public function dateAdd($date, $interval, $datePart)
725726
}
726727

727728
/**
728-
* Return correct regexp operator for Postgresql.
729-
*
730-
* Ensure that the regexp operator is Postgresql compatible.
729+
* Get the regular expression operator
731730
*
732731
* Usage:
733732
* $query->where('field ' . $query->regexp($search));
734733
*
735734
* @param string $value The regex pattern.
736735
*
737-
* @return string Returns the regex operator.
736+
* @return string
738737
*
739738
* @since __DEPLOY_VERSION__
740739
*/
@@ -744,18 +743,16 @@ public function regexp($value)
744743
}
745744

746745
/**
747-
* Return correct rand() function for Postgresql.
746+
* Get the function to return a random floating-point value
748747
*
749-
* Ensure that the rand() function is Postgresql compatible.
750-
*
751748
* Usage:
752-
* $query->Rand();
753-
*
754-
* @return string The correct rand function.
749+
* $query->rand();
750+
*
751+
* @return string
755752
*
756753
* @since __DEPLOY_VERSION__
757754
*/
758-
public function Rand()
755+
public function rand()
759756
{
760757
return ' RANDOM() ';
761758
}
@@ -769,10 +766,9 @@ public function Rand()
769766
* $query->findInSet((int) $parent->id, 'a.assigned_cat_ids')
770767
*
771768
* @param string $value The value to search for.
772-
*
773769
* @param string $set The set of values.
774770
*
775-
* @return string Returns the find_in_set() postgresql translation.
771+
* @return string A representation of the MySQL find_in_set() function for the driver.
776772
*
777773
* @since __DEPLOY_VERSION__
778774
*/

src/Sqlsrv/SqlsrvQuery.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,16 @@ public function group($columns)
272272
}
273273

274274
/**
275-
* Return correct rand() function for MSSQL.
276-
*
277-
* Ensure that the rand() function is MSSQL compatible.
275+
* Get the function to return a random floating-point value
278276
*
279277
* Usage:
280-
* $query->Rand();
278+
* $query->rand();
281279
*
282-
* @return string The correct rand function.
280+
* @return string
283281
*
284282
* @since __DEPLOY_VERSION__
285283
*/
286-
public function Rand()
284+
public function rand()
287285
{
288286
return ' NEWID() ';
289287
}
@@ -297,10 +295,9 @@ public function Rand()
297295
* $query->findInSet((int) $parent->id, 'a.assigned_cat_ids')
298296
*
299297
* @param string $value The value to search for.
300-
*
301298
* @param string $set The set of values.
302299
*
303-
* @return string Returns the find_in_set() Mysql translation.
300+
* @return string A representation of the MySQL find_in_set() function for the driver.
304301
*
305302
* @since __DEPLOY_VERSION__
306303
*/

0 commit comments

Comments
 (0)