[PHP-DB] SQL mailing list
Do any of you know of any good, general SQL discussion mailing lists? Preferably DB-independent. I'd like to find a place to ask SQL questions and get a human response... TIA, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Datetime field comparison incorrect
Hi, I'm querying 2 datetime fields from a MSSQL database. The format returned is 'Jul 06 2002 01:57PM' or similar. I then try to do a comparison in PHP, to see if one is greater than the other. The problem is that PHP believes 'Jul 06 2002 12:43PM' is greater than 'Jul 06 2002 01:08PM', which is obviously not true. Assuming that the first value mentioned is $var1, and the second $var2, here's how I'm comparing: if ($var1 $var2) { echo $var1.' is greater than '.$var2; } Thanks in advance, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Column headers
How can I get the column headers from a query? For example, on a 'select blah, blah2, blah3, something as blah4 from whereever', I would want the blah, blah2, blah3, blah4, preferably in an array. Thanks, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Column headers
Whoops, should have been more clear. I'm looking for something to work with ODBC, and also Sybase. I'm already fetching the data fine, but can't figure out how to get the column headers. On Tuesday 02 July 2002 09:50 am, Casey Allen Shobe wrote: How can I get the column headers from a query? For example, on a 'select blah, blah2, blah3, something as blah4 from whereever', I would want the blah, blah2, blah3, blah4, preferably in an array. Thanks, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Column headers
On Tuesday 02 July 2002 10:32 am, Bogdan Stancescu wrote: odbc_num_fields() and odbc_field_name() in this case :-) Thanks, that works! Now, any advice for sybase? There's a sybase_num_fields function, but nothing to get the columnname that I can see. Thanks again in advance, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Column headers
Following up. I found sybase_fetch_field, which fetches field information, including the column name, into an object. So now my question is, what is an object? And how would I go about getting the information I need out of it? Thanks. On Tuesday 02 July 2002 11:03 am, Casey Allen Shobe wrote: On Tuesday 02 July 2002 10:32 am, Bogdan Stancescu wrote: odbc_num_fields() and odbc_field_name() in this case :-) Now, any advice for sybase? There's a sybase_num_fields function, but nothing to get the columnname that I can see. -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Column headers
On Tuesday 02 July 2002 11:09 am, Casey Allen Shobe wrote: Following up. I found sybase_fetch_field, which fetches field information, including the column name, into an object. So now my question is, what is an object? And how would I go about getting the information I need out of it? Oh, and what's the difference between [int field_number] and [int field_offset] (from odbc_field_name and sybase_fetch_field manual pages)? Are they the same, or is the offset one number less than the field number, or is it something else entirely? -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] multiple queries in a row
On Thursday 27 June 2002 02:19 pm, Mattia wrote: I would like to make multiple queries in a single mysql_query(...) statement!! Like in the mysql client given with the distribution, separated by a ; or a \g !!! How can I??? You should be able to use it exactly the same. $foo = mysql_query(' select something fromsomewhere; select something_else fromsomewhere_else; ', $link_id); -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Resolved: [PHP-DB] Column headers
On Tuesday 02 July 2002 11:18 am, Casey Allen Shobe wrote: Oh, and what's the difference between [int field_number] and [int field_offset] (from odbc_field_name and sybase_fetch_field manual pages)? Are they the same, or is the offset one number less than the field number, or is it something else entirely? I've resolved this, thanks everyone! // Unified query function, including row count function db_query ($db_type, $db_query) { // Uncomment to debug //echo $db_query.'br'; if ($db_type == 'db2') { global $db2_conn; $result = odbc_exec ($db2_conn, $db_query); while (odbc_fetch_into ($result, $row)) { $data[0][] = $row; } $data[1] = odbc_num_rows ($result); for ($i = 1; $i = odbc_num_fields ($result); $i++) { $data[2][$i - 1] = odbc_field_name ($result, $i); } odbc_free_result ($result); } else if ($db_type == 'piv') { global $piv_conn; $result = sybase_query ('set textsize 32768'.\n.$db_query, $piv_conn); while ($row = sybase_fetch_array ($result)) { $data[0][] = $row; } for ($i = 0; $i sybase_num_fields ($result); $i++) { $temp = sybase_fetch_field ($result, $i); $data[2][$i] = $temp-name; unset ($temp); } $data[1] = sybase_num_rows ($result); } return $data; } -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Unified DB Query function
I'm trying to write a unified database query function for an application I have which currently accesses data from both DB2 and Microsoft SQL from a Linux server. I'm using ODBC functions for DB2, and Sybase functions for Microsoft SQL. Here's what I've got for DB2, and a blank area for MSSQL: function db_query ($db_type, $db_conn, $db_query) { // Uncomment to debug //echo $db_query.'br'; if ($db_type == 'odbc') { $result = odbc_exec($db_conn, $db_query); while(odbc_fetch_into($result, $row)) { $data[0][]=$row; } $data[0] = get_data ($result); $data[1] = odbc_num_rows ($result); odbc_free_result ($result); } else if ($db_type == 'sybase') { // What do I put here? } return $data; } If anyone could tell me what I could put in the sybase if statement to return data in an identical format as that returned by the odbc if statement, I would greatly appreciate it! I'm somewhat at a loss as the sybase commands are quite different from the odbc commands. Thanks in advance, -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Unified DB Query function
I figured it out. Here's my completed code for reference: $db2_conn = @odbc_connect (DB2_ALIAS, DB2_USERNAME, DB2_PASSWORD) or $db_error .= 'font size=+2bUnable to connect to DB2 Database!!/b/fontbr'.\n.'bfont color=#ccError Message: /font/b'.$php_errormsg.'br'; $piv_conn = @sybase_connect (PIV_ALIAS, PIV_USERNAME, PIV_PASSWORD) or $db_error .= 'font size=+2bUnable to connect to Pivotal Database!!/b/fontbr'.\n.'bfont color=#ccError Message: /font/b'.$php_errormsg.'br'; if (!isset($db_error)) { sybase_select_db ('Enterprise_Data', $piv_conn); } function db_query ($db_type, $db_query) { if ($db_type == 'db2') { global $db2_conn; $result = odbc_exec ($db2_conn, $db_query); while (odbc_fetch_into ($result, $row)) { $data[0][] = $row; } $data[1] = odbc_num_rows ($result); odbc_free_result ($result); } else if ($db_type == 'piv') { global $piv_conn; $result = sybase_query ('set textsize 32768'.\n.$db_query, $piv_conn); // What do I put here? while ($row = sybase_fetch_array ($result)) { $data[0][] = $row; } $data[1] = sybase_num_rows ($result); } return $data; } -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Unified DB Query function
On Monday 01 July 2002 01:55 pm, Manuel Lemos wrote: Why do you re-invent the wheeel and don't you use a database abstraction package that handles the database differences of you, like for instance Metabase. Because I had never heard of it. It doesn't appear to have a sybase module anyways, and they appear to be separate classes for each database, whereas I wanted one for all. Perhaps however I am misreading the site, but it won't let me very far without a username and password. -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Application name reporting
I'm currently using a PHP application to interact with DB2 and MSSQL (via FreeTDS). The application name reported to DB2 is httpd, and the application name reported to MSSQL is PHP 4.0. How can I replace these with my actual application's name? Thanks. Please CC me on replies as I do not keep up with all the traffic on this list. -- Casey Allen Shobe / Network Security Analyst PHP Developer SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144 [EMAIL PROTECTED] / http://www.secureworks.net Content is my own and does not necessarily represent my company. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php