@@ -535,37 +535,6 @@ public function delete(int $id): int
535535 return $ Query ->execute ();
536536 }
537537
538- /**
539- * Retrieve the count of records
540- *
541- * @param array $conditions
542- * @return int
543- */
544- public function count (array $ conditions = [], string $ conjunction = 'AND ' ): int
545- {
546- // Create the Query
547- $ Query = $ this ->Database ->query ()
548- ->table ($ this ->table )
549- ->select ($ this ->primary )
550- ->where ('id ' , 9999 , '<> ' );
551-
552- // Check for ownership
553- if (array_key_exists ('organization ' ,$ this ->definition )){
554- $ Query ->where ('organization ' , $ this ->Auth ->user ()->organization ()->id );
555- }
556-
557- // Add the Conditions
558- foreach ($ conditions as $ condition ){
559- $ Query ->where ($ condition ["key " ], $ condition ["value " ], $ condition ["operator " ], $ conjunction );
560- }
561-
562- // Execute the Query
563- $ records = $ Query ->fetch ();
564-
565- // Return the Count
566- return count ($ records );
567- }
568-
569538 /**
570539 * Retrieve multiple records
571540 *
@@ -624,6 +593,17 @@ public function fetchAll(array $conditions = [], string $conjunction = 'AND'): a
624593 return $ records ;
625594 }
626595
596+ /**
597+ * Retrieve the count of records
598+ *
599+ * @param array $conditions
600+ * @return int
601+ */
602+ public function count (array $ conditions = [], string $ conjunction = 'AND ' ): int
603+ {
604+ return count ($ this ->fetchAll ($ conditions , $ conjunction ));
605+ }
606+
627607 /**
628608 * Retrieve a single record
629609 *
0 commit comments