Re: [PHP-DB] Re: Why varying functionality across php db apis for db metadata?
Jason Wong wrote: On Wednesday 17 September 2003 18:46, pete M wrote: Mike Klein wrote: For example, php mysql library supports list_dbs and list_tables commands as well as getting table metadata. MySQL sql also 'natively' supports these commands (show databases, show tables, describe tableName). Why not similar commands for Oracle, SQLServer, etc.? These are simply selects against certain system tables, no? Go and ask M$ and Oracle.. I doubt whether they have anything to do with it (although it's nice to blame everything on M$), but rather it is author(s) of the particular DB extensions who you have to thank for the current inconsistencies. I think some move is being made to make the commands consistent across the different DBs. Eg the names of the postgresql functions are being changed to match those of the mysql functions. I've been so impressed with the capabilities of php in general, that I am a little surprised more effort wasn't made at consistency from the get go...something ala jdbc or whatever. Other php db libs I've seen don't offer common database metadata functions, only wrappers for basic functionality. You need the metadata functions when writing query tools/browsers/etc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Free php-based mysql browser/query tool available for download...
Sorry it's for mysql only...but this merely reflects the current state of php's database support...especially regarding functions for retrieving database metadata. Current support is for pointclick browsing and simple queries. I will be adding support for joins, calculated columns, and more in the coming weeks. As this was my first php project (don't use this as a reason to not download...it works fine) I would appreciate greatly any feedback regarding shortcuts, innefficiencies, bugs, etc. For downloading instructions and a demo, please see: http://www.vxappliance.com/developers/shareware/databaseExplorers Personally I use phpMyAdmin or the mysql cmdline (like everybody else) for admin tasks, but I wanted a simple front-end for the rest of my website without all of phpMyAdmin's baggage (ui and otherwise). mike klein -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Why varying functionality across php db apis for db metadata?
For example, php mysql library supports list_dbs and list_tables commands as well as getting table metadata. MySQL sql also 'natively' supports these commands (show databases, show tables, describe tableName). Why not similar commands for Oracle, SQLServer, etc.? These are simply selects against certain system tables, no? mike klein -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Help needed with variable scoping? or mysql problem
Oh yeah that's the ticket! I'd forgotten that I'd removed the mysql_select_db statement when doing some earlier 'cleanup'. It just so happens that a few of the mysql metadata calls (like listing fields/etc.) were inadvertently setting the db...but only for a brief period of time...wierd. As I mentioned, I just started using php yesterday, so I'm still learning some tips/tricks. But...to php's credit, I gotten a fairly functional rdbms explorer/browser/editor going in under a day. I had initially planned on 'hardcoding' some rdbms master/detail forms, but after doing just one of them, and seeing the plethora of mysql calls available, I decided to genericize the code, and now it's a general explorer/etc. for all of my databases. Seems pretty speedy too. Now I just need to add result set 'scrolling'. Returning 2000 records is not nice... thanks buddy... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 8:10 AM To: Mike Klein Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Help needed with variable scoping? or mysql problem best way to tell is to place .'or die(mysql_error())' after any call to mysql_query() to see what mysql is complaining about. personally I sometimes declare the query first so i can echo that as well after the msyql_error() function, so i can see the query that has just been excecuted. helpful with dynamic queries. $qry = SELECT * FROM $tableName where $fieldName='$fieldValue'; $result = mysql_query($qry, $conn) or die(mysql_error() . $qry); hth jeff Mike Klein [EMAIL PROTECTED]To: [EMAIL PROTECTED] rg cc: Subject: [PHP-DB] Help needed with variable scoping? or mysql problem 08/14/2003 08:58 AM I've been using JSP for some time now, and thought I'd write a couple of rdbms explorers (flat tables, simple master/detail paradigm) using other technologies, like PHP, Cocoon, etc. Well...it's been fun. I have more working than not. But now I am hung up. I am getting wierd results in a php script when I simply change the order of some mysql calls. I'm using php-4.3.2, rh9, and mysql 3.23. My error is the following (the first line above the Warning below is a dump of parameters to the showMaster function which is what's bombing): conn=Resource id #3 databaseName=info tableName=movies fieldName=title fieldValue=36th Chamber Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /foo/bar/mywebsite/private/database.php on line 107 Line 107 is the first mysql_num_rows call below. function showMaster($conn, $databaseName, $tableName, $fieldName, $fieldValue) { echo conn=$conn\n; echo databaseName=$databaseName\n; echo tableName=$tableName\n; echo fieldName=$fieldName\n; echo fieldValue=$fieldValue\n; This code fails when placed here== $result = mysql_query(SELECT * FROM $tableName where $fieldName='$fieldValue', $conn); $numRows = mysql_num_rows($result); if(mysql_num_rows($result) == 1) { showDetail($conn, $databaseName, $tableName, $fieldName, $fieldValue, $result); exit; } echo numRows=$numRows\n; $fields = mysql_list_fields($databaseName, $tableName, $conn); $numFields = mysql_num_fields($fields); echo TABLE border=1 width=100%\n; echo tr; for($i = 0; $i $numFields; $i++) { printf(td%s/td, mysql_field_name($fields, $i)); } echo /tr; The SAME code succeeds when placed here!== $result = mysql_query(SELECT * FROM $tableName where $fieldName='$fieldValue', $conn); $numRows = mysql_num_rows($result); if(mysql_num_rows($result) == 1) { showDetail($conn, $databaseName, $tableName, $fieldName, $fieldValue, $result); exit; } echo numRows=$numRows\n; while($myrow = mysql_fetch_array($result)) ...rest of method... } Any ideas on why this is? When I move the lines above (from $result=...to...echo 'numRows') down a few lines to just before the mysql_fetch_array, then everything works. Whazzup?!? mike klein -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help needed with variable scoping? or mysql problem
I've been using JSP for some time now, and thought I'd write a couple of rdbms explorers (flat tables, simple master/detail paradigm) using other technologies, like PHP, Cocoon, etc. Well...it's been fun. I have more working than not. But now I am hung up. I am getting wierd results in a php script when I simply change the order of some mysql calls. I'm using php-4.3.2, rh9, and mysql 3.23. My error is the following (the first line above the Warning below is a dump of parameters to the showMaster function which is what's bombing): conn=Resource id #3 databaseName=info tableName=movies fieldName=title fieldValue=36th Chamber Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /foo/bar/mywebsite/private/database.php on line 107 Line 107 is the first mysql_num_rows call below. function showMaster($conn, $databaseName, $tableName, $fieldName, $fieldValue) { echo conn=$conn\n; echo databaseName=$databaseName\n; echo tableName=$tableName\n; echo fieldName=$fieldName\n; echo fieldValue=$fieldValue\n; This code fails when placed here== $result = mysql_query(SELECT * FROM $tableName where $fieldName='$fieldValue', $conn); $numRows = mysql_num_rows($result); if(mysql_num_rows($result) == 1) { showDetail($conn, $databaseName, $tableName, $fieldName, $fieldValue, $result); exit; } echo numRows=$numRows\n; $fields = mysql_list_fields($databaseName, $tableName, $conn); $numFields = mysql_num_fields($fields); echo TABLE border=1 width=100%\n; echo tr; for($i = 0; $i $numFields; $i++) { printf(td%s/td, mysql_field_name($fields, $i)); } echo /tr; The SAME code succeeds when placed here!== $result = mysql_query(SELECT * FROM $tableName where $fieldName='$fieldValue', $conn); $numRows = mysql_num_rows($result); if(mysql_num_rows($result) == 1) { showDetail($conn, $databaseName, $tableName, $fieldName, $fieldValue, $result); exit; } echo numRows=$numRows\n; while($myrow = mysql_fetch_array($result)) ...rest of method... } Any ideas on why this is? When I move the lines above (from $result=...to...echo 'numRows') down a few lines to just before the mysql_fetch_array, then everything works. Whazzup?!? mike klein -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php