File tree 1 file changed +53
-0
lines changed
1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,59 @@ public static function prepareParams($data, $params)
393
393
return $ return ;
394
394
}
395
395
396
+ /**
397
+ * Get all the tables present in the DP database
398
+ *
399
+ * @return array
400
+ */
401
+ public function getTables ()
402
+ {
403
+ return $ this ->callSql ("
404
+ SELECT
405
+ *
406
+ FROM
407
+ INFORMATION_SCHEMA.TABLES;
408
+ " );
409
+ }
410
+
411
+ /**
412
+ * Get all the columns present in the provided table
413
+ *
414
+ * @param string $table
415
+ * @return array
416
+ */
417
+ public function getColumns (string $ table )
418
+ {
419
+ return $ this ->callSql ("EXEC sp_columns $ table " );
420
+ }
421
+
422
+ /**
423
+ * Get an array with all the tables that have at least 1 row along with the number of rows present in the given table
424
+ *
425
+ * @return array
426
+ */
427
+ public function getTablesAndRowCounts ()
428
+ {
429
+ return $ this ->callSql ("
430
+ SELECT
431
+ t.NAME AS TableName,
432
+ p.rows AS RowCounts
433
+ FROM
434
+ sys.tables t
435
+ INNER JOIN
436
+ sys.indexes i ON t.OBJECT_ID = i.object_id
437
+ INNER JOIN
438
+ sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
439
+ WHERE
440
+ t.is_ms_shipped = 0
441
+ AND p.rows > 0
442
+ GROUP BY
443
+ t.Name, p.Rows
444
+ ORDER BY
445
+ t.Name
446
+ " );
447
+ }
448
+
396
449
/**
397
450
* List all available donors in the system.
398
451
*
You can’t perform that action at this time.
0 commit comments