pdo-wrapper icon indicating copy to clipboard operation
pdo-wrapper copied to clipboard

Unclear how to implement SHOW TABLES query

Open wpebley opened this issue 2 years ago • 0 comments

Hi!

Love your PDO Wrapper! I am successfully using it in a large project and it has significantly cut down on my code size.

I hope you'll pardon my ignorance here, but it is unclear to me how I go about reading in and storing the results of TABLE SHOW using the wrapper. In regular PDO code, I am using the following...

//Execute the SHOW TABLE query
 try {
     $conn = new PDO(...);
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $stmt = $conn->prepare("SHOW TABLES");
     $stmt->execute();
 }
 catch(PDOException $e){
     echo "Error: " . $e->getMessage();
 }

 //Build array from the resulting SQL file rows

 $table= [];

 $row = 0;
 while ($r = $stmt->fetch(PDO::FETCH_NUM)) {
     $table[$row] = $r[0];
     $row = $row + 1;
 }       

This is the last piece that will allow me to have converted the entire project to your wrapper. Any guidance will be appreciated.

Thx,

Bill

wpebley avatar Sep 09 '23 13:09 wpebley