Re: [PHP-DB] DB interface problem
Why not using PDO ? It is a global and standardized method to access to data. :-) 2009/10/27 Giff Hammar : > I started having trouble with a DBI interface to my PostgreSQL database > after I built a new Ubuntu machine. The Postgres version is 8.3 and the > DBI was written several years ago (by someone else). I'm using PHP > version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the > error: > > Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL > result resource in /var/www/lib/dbi_pgsql.php on line 202 > > I don't know what to check next to figure out why this is happening. > Here is what I have done so far: > > - Updated the old PHP commands in the dbi file to reflect new ones > var -> public > pg_numrows -> pg_num_rows > pg_cmdtuples -> pg_affected_rows > pg_exec -> pg_execute > - Connected to the database as the same user by using straight PHP calls > vs the DBI. It worked fine. > - Connected to the database via psql and that worked fine, too. > > There is something with the DBI class that is not right, but I am a > novice with objects and classes, so I can't pin it down. The whole file > is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines so I > didn't want to put the whole thing in this post. > > If anyone can take a look at it and let me know what to check next, I > would really appreciate it. > > Giff > > > -- > 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
Re: [PHP-DB] PDO PgSQL: _pdo_pgsql_notice
To use PostgreSQL's Notices with PDO, i'm modifying the source for trying to store into "errmsg" (which I can get with PDO::errorInfo) the notice. The "_pdo_pgsql_notice" function is called everytime that there's an notice. The notice message is in the "message" var. This what i had tried: --- static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_error_info *einfo = &H->einfo; einfo->errcode = 1; if (einfo->errmsg) { pefree(einfo->errmsg, dbh->is_persistent); einfo->errmsg = NULL; } einfo->errmsg = _pdo_pgsql_trim_message(message, dbh->is_persistent); } --- And in "pdo_pgsql_fetch_error_func", i've added an else condition to view if errmsg is null are not... --- if (einfo->errcode) { add_next_index_long(info, einfo->errcode); add_next_index_string(info, einfo->errmsg, 1); } else { zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "einfo->errcode is false : %s , %s", einfo->errcode, einfo->errmsg); } --- And, I've a function which send some notices (when I throw exception from "_pdo_pgsql_notice" with the "message" var, I see the notice ! :-) But, einfo->errcode is null ! -> Fatal error: Uncaught exception 'PDOException' with message 'einfo->errcode is false : (null) , (null)' in /etc/php-5.2.10/test/pgsql_notice.php:22 Stack trace: #0 /etc/php-5.2.10/test/pgsql_notice.php(22): PDO->errorInfo() #1 {main} thrown in /etc/php-5.2.10/test/pgsql_notice.php on line 22 Is anyone can help me ? Thanks a lot ! Samuel. (French) Le lundi 05 octobre 2009 à 20:58 +0200, Samuel ROZE a écrit : > Hi ! > > I'm reading the source of PDO PostgreSQL driver and i see that there's > an empty function, _pdo_pgsql_notice, which is very interesting ! I > think that it is used when PostgreSQL throw Notices. > But, nothing is done... > > I want to know if somebody know why the content of the function is > commented: > > static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* > {{{ */ > { > /*pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ > } > > (line 98 of /etc/pdo_pgsql/pgsql_driver.c - PHP 5.2 - r272374) > > How can I store the content of "message" into a field of the > PDOStatement ? I view that there's only a "pdo_dbh_t" param, I may just > store this message into a field of the PDO class ? > > Thanks in advance. > Samuel. > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PDO PgSQL: _pdo_pgsql_notice
Hi ! I'm reading the source of PDO PostgreSQL driver and i see that there's an empty function, _pdo_pgsql_notice, which is very interesting ! I think that it is used when PostgreSQL throw Notices. But, nothing is done... I want to know if somebody know why the content of the function is commented: static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ { /* pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ } (line 98 of /etc/pdo_pgsql/pgsql_driver.c - PHP 5.2 - r272374) How can I store the content of "message" into a field of the PDOStatement ? I view that there's only a "pdo_dbh_t" param, I may just store this message into a field of the PDO class ? Thanks in advance. Samuel. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PDO and PostgreSQL - RAISE NOTICE
Thanks a lot ! I'm now understanding why PDO exists.. It is not for replace the actual PostgreSQL/MySQL/SQLite/Firebird/... PHP drivers but for help to developp with many DB with one code. Well... I can developp an extension to PDO PostgreSQL driver, is that correct ? It may help many users like me... :-) Thanks Lester ! Samuel. Le lundi 05 octobre 2009 à 08:36 +0100, Lester Caine a écrit : > Samuel ROZE wrote: > > Hi, > > Thanks for your reply. > > > > In fact, my request returns a result which i get with the fetch method. > > But, it must returns other informations, which are not in the result... > > This informations are neturned before the result in console... > > > > So, i don't know how I can get that. > > PDO does not support many of the 'additional' features that databases > provide. It's designed to provide a 'lowest common denominator' solution > JUST for the data. If you are NOT planning to use any other database > then you may well find that the native postgres driver will provide > these additional facilities. > > I use Firebird myself so can't comment on the 'fine detail' on postgres, > but some of the Firebird options can't easily be supported in PDO ;) > > -- > Lester Caine - G8HFL > - > Contact - http://lsces.co.uk/wiki/?page=contact > L.S.Caine Electronic Services - http://lsces.co.uk > EnquirySolve - http://enquirysolve.com/ > Model Engineers Digital Workshop - http://medw.co.uk// > Firebird - http://www.firebirdsql.org/index.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need help in triggers
What are you really want to do ? This is an exemple: CREATE FUNCTION myfunction () RETURNS trigger AS $$ BEGIN NEW.update_date = 'now'::date; RETURN NEW; END; $$ LANGUAGE plpgsql; CREATE TRIGGER set_update_date AFTER INSERT ON matable FOR EACH ROW EXECUTE PROCEDURE myfunction(); Le lundi 05 octobre 2009 à 14:36 +0530, Yogendra Kaushik a écrit : > Hi all's >i am working on an application in which we are using PostgreSql as an > database, i need to write trigger for my application. Can any one help me > how can i write it. > i have try to write it, but did not get success. > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PDO and PostgreSQL - RAISE NOTICE
Hi, Thanks for your reply. In fact, my request returns a result which i get with the fetch method. But, it must returns other informations, which are not in the result... This informations are neturned before the result in console... So, i don't know how I can get that. Samuel. Le lundi 05 octobre 2009 à 09:55 +1100, Kesavan Rengarajan a écrit : > Hi, > Query returns an iterable object (thanks to the comments in the php > site) and that's why when you do a dump you just see the String, > If you just want to get one row from the resultset you can get it like > this: > $stat = $sql->query('SELECT * FROM public.test_info()')->fetch(); > > More information on the PDO::query method can be found here: > http://au.php.net/manual/en/pdo.query.php > > Cheers > Sent from my iPhone > > On 05/10/2009, at 2:06 AM, Samuel ROZE wrote: > > > Hi ! > > > > I'm new on this mailling list, so i don't realy know if you know the > > response and if it is realy here that I have to ask my question :-) > > > > I'm working with PostgreSQL (8.3 form sources) and PDO (PHP 5.2.10 > > from > > sources). In a Postgres function, I have a "RAISE NOTICE" command. My > > function works like that in console: > > > > => SELECT * FROM public.test_info(); > > NOTICE: An information... > > > > test_info > > > > ok > > (1 line) > > > > There's a NOTICE, like I want ! :-) But, when i'm using PDO, I don't > > know how I can get this NOTICE, which will provide me some > > informations > > about the usage of the function. > > > > Code: > > -- > > > $sql = new PDO('...'); > > > > $stat = $sql->query('SELECT * FROM public.test_info()'); > > var_dump($stat); > > ?> > > -- > > > > Output: > > ------ > > object(PDOStatement)#4 (1) { > > ["queryString"]=> > > string(34) "SELECT * FROM public.test_info()" > > } > > -- > > > > Is there someone who know how I can get that ? I read some thinks > > about > > that and pg_last_notice may returns the NOTICE, but with PDO ? > > > > Thanks ! > > Samuel (French). > > > > > > -- > > 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] PDO and PostgreSQL - RAISE NOTICE
Hi ! I'm new on this mailling list, so i don't realy know if you know the response and if it is realy here that I have to ask my question :-) I'm working with PostgreSQL (8.3 form sources) and PDO (PHP 5.2.10 from sources). In a Postgres function, I have a "RAISE NOTICE" command. My function works like that in console: => SELECT * FROM public.test_info(); NOTICE: An information... test_info ok (1 line) There's a NOTICE, like I want ! :-) But, when i'm using PDO, I don't know how I can get this NOTICE, which will provide me some informations about the usage of the function. Code: -- query('SELECT * FROM public.test_info()'); var_dump($stat); ?> -- Output: -- object(PDOStatement)#4 (1) { ["queryString"]=> string(34) "SELECT * FROM public.test_info()" } -- Is there someone who know how I can get that ? I read some thinks about that and pg_last_notice may returns the NOTICE, but with PDO ? Thanks ! Samuel (French). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] & and sessions
Bobo Wieland wrote: how can i force the SID variable in urls not to be &SID=, but &SID ? Who is appending SID to your urls? You or php?? I currently append SID via code (not automatically by php), and its working well with XHTML 1.1. Otherwise, take a look at this php.ini option -> ; The separator used in PHP generated URLs to separate arguments. ; Default is "&". ;arg_separator.output = "&" It may be what you're looking for... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] preg_math vs preg_match_all
Yemi Obembe wrote: Just want to know the difference between preg_match and preg_match_all. preg_match stops after the first match. preg_match_all gets *all* the matches. E.g. If you have a string -> $str = "foofoo"; preg_match('/foo/', $str, $match); -> $match will have an array with one "foo". preg_match_all('/foo/', $str, $match); -> $match will have an array with two "foo". Thats basically it. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Norland, Martin wrote: The functions you want exist in php5, if that's an option: http://us2.php.net/manual/en/ref.mysqli.php -> http://us2.php.net/manual/en/function.mysqli-fetch-assoc.php No this is not an option. mysqli_fetch_* needs a "result" resource id to work. mysqli statement functions needs object references (plus there are other quirks). You cannot use mysqli_fetch_* functions with the mysqli prepared statement functions... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Hans Lellelid wrote: Hi Georg, Am Di, den 26.10.2004 schrieb Hans Lellelid um 12:57: Ooops, I guess I should have searched the list itself; I did some google searches to no avail. This is really unfortunate. This API sucks! Prepared api calls use a binary protocol, which is totally different from the "old" protocol. If you don't need binary protocol for prepared statements, why don't you use native SQL Implementation for prepared statements instead ?? What is "native SQL Implementation for prepared statments"? All I want to do is use prepared statements in a non-emulated way. Like ODBC, OCI8, mssql callable statements, etc. I want the speed improvement of using non-emulated prepared statements. I believe he is talking about -> http://dev.mysql.com/doc/mysql/en/SQLPS.html But IMHO, I think emulating via php would be faster, as that is alot of talking to a database to get the job done, especially if the database is on a remote host. It's always easy to claim that stuff other people created (and spent a lot of time on it) sucks. But it sucks definitely more, if people are not able to read the PHP and MySQL Documentation carefully. Yes, it is easy, you're right. :) I was looking forward to the speed increase of using native prepared statements, but it is not useful for anything I'm doing if the prepared statement API is completely different from standard queries. I don't think that there's an issue with documentation here. The behavior of mysqli is consistent with everything I read, I just couldn't believe that it was actually implemented that way. Anyway, I assume this is a MySQL API, and doesn't have anything to do with the PHP port. Hopefully PDO can / does take advantage of the native prepared statements without the exceptional API. Granted, he is correct. We have no right to say that is sucks. Me personally, I do not know at whom to point a finger to blame (maybe the mysql C API), but it is what it is unfortunately. We just have to make the best of it... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli prepared statement query result sets
Hans Lellelid wrote: Hi, I'm writing a db abstraction layer driver for MySQLi. I'm glad to finally get a chance to play around with these new functions, but am completely stumped by this question: Is there no way to get back a standard resultset when using prepared statement queries? I can't believe this would be the case, but it seems that the only option when using prepared statements is to call myslqi_stmt_bind_result(), binding results to php variables and then call mysqli_stmt_fetch($stmt) until it returns null. i.e. $sql = "SELECT name, age FROM friends WHERE country = ?"; $stmt = mysqli_prepare($link, $sql); $country = "Haiti"; mysqli_bind_param($stmt, "s", $country); mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt, $name, $age); /* fetch values */ while (mysqli_stmt_fetch($stmt)) { printf ("%s (%s)\n", $name, $code); } What I want to be able to do is use things like mysqli_fetch_assoc() instead of this weird, side-effect-prone mysqli_stmt_fetch() to retrieve the results. I don't see the solution, but I hope I'm just missing something because I've been staring at it too long. No you're not missing anything... I ran into the same thing... http://marc.theaimsgroup.com/?l=php-db&m=109625996830773&w=2 So I ended up simulating "prepared" statements via php itself. The way the mysqli extension is currently setup, is that you can either use the normal functions by themselves, or you use the statement functions by themselves. They cannot be used together, which I think Never mind, I'll keep my thoughts to myself... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] INNO tables - will I have problems?
[EMAIL PROTECTED] wrote: If the minimum requirement of mysql is version 4, then you will have no problems, as INNODB is the default type in mysql 4.x.x -- InnoDB is included by default in mysql 4 but the default is still MyISM. I looked over the manual, and I believe that you are correct. The default type is still MyISAM, but to create an INNODB table, one must specify it in the CREATE TABLE syntax... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] INNO tables - will I have problems?
Julian Madle wrote: I obviously have no control of which ISP and end-user may choose, although our product will specify that Linux, PHP4, and MySQL4 (or higher) are installed. The manual says that these are built-in on version 4.0 and above - I just need real-world confirmation from people with more experience in this area than me. If the minimum requirement of mysql is version 4, then you will have no problems, as INNODB is the default type in mysql 4.x.x -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] One to Many Select Statement
John Holmes wrote: Gerard Samuel wrote: Looking for clarification... Say that I have a user table and group table -> -- user table -- id username 1 foo -- group table -- id user_id group_name 1 1group_1 2 1group_2 Would this be the proper way to construct a select statement for this -> select u.username, g.group_name from user u, group g where u.user.id = g.user_id and user.id = 1; The results should look like this -> username group_name foo group 1 foo group 2 What I would like to clarify, is if this is the proper (only) way to construct a one to many select statement? I've always thought I was doing something illegal, since username is displayed more than once, and I would like to shake that thought off my back. Other than using "u.user.id" and "user.id" instead of "u.id" (just typos, I'm sure), Man, and I proof read the message before I sent it out. ;) there's nothing really wrong with that query. Good. You can do that join this way, though, which may be more "proper": SELECT u.username, g.group_name FROM user u JOIN group g ON u.id = g.id WHERE u.id = 1 Thanks for the tip... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] One to Many Select Statement
Looking for clarification... Say that I have a user table and group table -> -- user table -- id username 1 foo -- group table -- id user_id group_name 1 1group_1 2 1group_2 Would this be the proper way to construct a select statement for this -> select u.username, g.group_name from user u, group g where u.user.id = g.user_id and user.id = 1; The results should look like this -> username group_name foo group 1 foo group 2 What I would like to clarify, is if this is the proper (only) way to construct a one to many select statement? I've always thought I was doing something illegal, since username is displayed more than once, and I would like to shake that thought off my back. Thanks for your input.. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Space requirements (with respect to foriegn languages)
My site/code/database is developed primarily for the english language. I've had people from "The Far East" add content to my site using their native language, and it is displaying properly in the site. But Im a bit concerned about the number of characters these languages use. For example, I've had someone enter -> chinese testingãäæ It is saved in the database as -> chinese testing 中文 Now, forgive my ignorance, but I have no idea what the additional chinese characters mean, but from the values in the database, Im assuming that it amounts to 3 characters. But if Im correct that those are 3 characters, it is using up 24 characters in a column. My concern is that what if I were to limit a column to say 25 "english" characters, and a chinese fellow, comes by and hypothetically says "Hello World" in chinese and goes over the limit of the column, the data will be truncated. Is there anything that can be done to overcome this shortcoming? Im currently using PostgreSQL 7.4.2, using SQL_ASCII as the database characterset, FreeBSD 4.10, php 4.3.6. Thanks for any advise you can provide... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] IBM DB2
Robert Twitty wrote: On Thu, 19 Aug 2004, Gerard Samuel wrote: Robert Twitty wrote: Hi Is anyone using PHP to connect to an IBM DB2 database? The reason why I am asking is becaouse I want to see if the odbtp extension can be used to successfully prepare and execute DB2 stored procedures. So far, ODBTP performs quite well with IBM DB2 in regards to regular queries. I've never used stored procedures before, but if you have example code on hand, I can give it a shot... Unfortunately, I do not have access to an IDM DB2 database, so I don't have any examples of my own. However, after "Googling", I have discovered that creating DB2 stored procedures is a bit more complex than that of other databases, like SQL Server and Oracle. It appears that DB2 stored procedures are implemented as external shared libraries, i.e., DLLs. The examples that I found were written in C. So, testing ODBTP with DB2 stored procedures may be beyond the call of duty. Unfortunately, I trashed my dev box by fdisking it last week. Hopefully in the next week or two, when I get some time, I'll be rebuilding it, and I'll take a look at stored procedures to see if its doable or not. I know where to find you... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] IBM DB2
Robert Twitty wrote: Hi Is anyone using PHP to connect to an IBM DB2 database? The reason why I am asking is becaouse I want to see if the odbtp extension can be used to successfully prepare and execute DB2 stored procedures. So far, ODBTP performs quite well with IBM DB2 in regards to regular queries. I've never used stored procedures before, but if you have example code on hand, I can give it a shot... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DB2 +Windows +CLOB
On Tuesday 03 August 2004 09:02 am, Robert Twitty wrote: > The odbtp extension has be used quite successfully with DB2. You can get > it at http://odbtp.sourceforge.net. I have not personnally used it with > DB2, but there are posts on odbtp's help forum pertaining to DB2. > > -- bob > > On Tue, 3 Aug 2004, Javier Mestre wrote: > > Any example how to use CLOB,BLOB fields with PHP under Windows and DB2 ? > > I use Robert's odbtp extension with DB2, with CLOB columns without any problems (haven't tried BLOB), on my dev box. There aren't any hoops to jump through, like when using php's native odbc extension. Granted I've only used it on a dev box, and not in production, means that I can say if it (odbtp) will handle all situations with BLOB/CLOB, so any experiences that you can provide would be great (that is if you run into any ;))... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Prepared statements via mssql extension
Is it possible? Just checking... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: SQL injection & prepared statements
On Friday 25 June 2004 01:03 pm, Hans_L wrote: > Gerard Samuel wrote: > > > > So Im guessing that this is how "prepared" statements are done on other > > databases. > > > > After being trained to do it one way (always escaping "bad" content), Im > > being shown to do it the other way, and Im looking for any suggestions > > you may have. > > Yes, the idea with prepared statements is that the database (or > transport layer, etc.) knows how to properly escape the values. Thanks for your reply. I wasn't sure who was respondsible for "cleaning up" data sent to the db. So I guess Ill continue with the thought that prepared statements (in databases that can use it) takes care of it. Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQL injection & prepared statements
Just looking for opinions on sql injection while using prepared statements. I've read at the oci8 extention that content should not be "escaped" --- Do not use magic_quotes_gpc or addslashes() and oci_bind_by_name() simultaneously as no quoting is needed and any magically applied quotes will be written into your database as oci_bind_by_name() is not able to distinguish magically added quotings from those added intentionally. --- I've also been told something similar to this from the author of the ODBTP php extention (http://odbtp.sourceforge.net/). So Im guessing that this is how "prepared" statements are done on other databases. After being trained to do it one way (always escaping "bad" content), Im being shown to do it the other way, and Im looking for any suggestions you may have. Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [sqlite] Re:SQLite ODBC Driver
On Wednesday 02 June 2004 02:55 am, David Morel wrote: > What do you mean? SQLite installation is the simplest thing ever! > > Change your ISP. Go for a real hosting service. > They sound like they *dont* know how to install it, and *dont* even want to try. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using Cursors
A bit off topic, but lately I've been running into situations, where I have to know about using cursors with databases, like sql server, ibm db2 Can anyone point me to online resources that explains (to a practical newbie) "cursors" Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [Attn] Re: [PHP-DB] SQLite behaving bad?
On Tuesday 17 February 2004 04:41 pm, Gerard Samuel wrote: > Currently using sqlite 2.8.11 (distributed by php snaps) with php4.3.5rc2 > on windows XP. > Several months ago, I added support for sqlite in a database abstraction > class I created. It worked great then. > Im trying to see if things are still ok today, and its not. > For example executing the select query -> > select f.foo, b.bar from table f, table b where f.id = b.id; > Should return result table fields "foo" and "bar". > Instead its returning result table fields "f.foo" and "b.bar". > Just an update about this. Due to changes in SQLite, the problem that I've described in this email, is now the default behaviour of SQLite. So if you get bitten by this, its up to you to figure a way around this. > Example script > > // sqlite connection parameters produce $conn resource id > > $sql = 'SELECT f.foo, b.bar FROM table f, table b WHERE f.id = b.id'; > $result = sqlite_query($conn, $sql); > if ($result === false) > { >die('For some reason'); > } > > while($row = sqlite_fetch_array($result, SQLITE_ASSOC)) > { > // The expected results return nothing > var_dump($row['foo'], $row['bar']); > > // The unexpected results return data > var_dump($row['f.foo'], $row['b.bar']); // You get the correct values > } > > ?> > > So has anyone experienced this with the current sqlite/php combination? > This used to work correctly with sqlite 2.8.3 (distributed by php snaps) > Were there any notices that I may have missed over these past months?? > > Thanks for any help you may provide... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQLite behaving bad?
Currently using sqlite 2.8.11 (distributed by php snaps) with php4.3.5rc2 on windows XP. Several months ago, I added support for sqlite in a database abstraction class I created. It worked great then. Im trying to see if things are still ok today, and its not. For example executing the select query -> select f.foo, b.bar from table f, table b where f.id = b.id; Should return result table fields "foo" and "bar". Instead its returning result table fields "f.foo" and "b.bar". Example script So has anyone experienced this with the current sqlite/php combination? This used to work correctly with sqlite 2.8.3 (distributed by php snaps) Were there any notices that I may have missed over these past months?? Thanks for any help you may provide... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] chmod on win xp
On Saturday 17 January 2004 03:17 pm, mayo wrote: > so I would like to write to file on my local box. > I've looked but I don't see how to chmod. > > using: windows xp and iis 5 > > -- gil 1. This is the Database list, stuff like this should go in the General List. 2. chmod only applies to *nix systems. It doesn't do anything on win32 systems. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] [PHP-DB] pg_result_error()
On Friday 12 December 2003 10:24 am, Martin Marques wrote: > > That is fine and all, but my original example was just an example of the > > non functionality of pg_result_error(), not how to handle errors when a > > query fails. > > But for arguement sake, lets use your example in some dummy code[0]. > > $result is still boolean false, and pg_result_error() will still return > > an empty string, and using die, would just die, with no report of what > > happened. Then whats the use of pg_result_error(). > > Looks like you are totally right. Tried it and it works horrible. Any idea > on why this is like this? > Seems like Im not the only one who thought this function is useless... http://bugs.php.net/bug.php?id=18747 So Im going to modify my code to not use this function, as it is really a total waste of time at the moment. Thanks for the chat... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_result_error()
Im going to CC this to the PostgreSQL list also. On Friday 12 December 2003 06:44 am, Martin Marques wrote: > El Vie 12 Dic 2003 00:09, Gerard Samuel escribió: > > What good is this function? > > A quick example of the wall Im running into -> > > $sql = 'INSERT INTO .'; > > $result = pg_query($conn_id, $sql); > > if ($result === false) > > { > > var_dump( pg_result_error( $result ) ); > > I would use here this: > die(pg_result_error( $result )); That is fine and all, but my original example was just an example of the non functionality of pg_result_error(), not how to handle errors when a query fails. But for arguement sake, lets use your example in some dummy code[0]. $result is still boolean false, and pg_result_error() will still return an empty string, and using die, would just die, with no report of what happened. Then whats the use of pg_result_error(). > > According to the manual, pg_result_error takes the result resource. > > If that resource is boolean false for one reason or another, then > > pg_result_error isn't useful. > > Anyone has any other ideas, besides using > > pg_last_error()? > > Did you try it? Yes I've tried it. In my DB class, Im currently using both pg_result_error() and pg_last_error(), with pg_last_error() being secondary (a fall back) to pg_result_error(). Because according to the manual -> http://us2.php.net/manual/en/function.pg-last-error.php --quote-- Error messages may be overwritten by internal PostgreSQL(libpq) function calls. It may not return appropriate error message, if multiple errors are occured inside a PostgreSQL module function. Use pg_result_error(), pg_result_status() and pg_connection_status() for better error handling. --quote-- So again, I beg the question. What good is pg_result_error(), when you *must* feed it boolean false and it returns an empty string?? [0] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] pg_result_error()
What good is this function? A quick example of the wall Im running into -> $sql = 'INSERT INTO .'; $result = pg_query($conn_id, $sql); if ($result === false) { var_dump( pg_result_error( $result ) ); } According to the manual, pg_result_error takes the result resource. If that resource is boolean false for one reason or another, then pg_result_error isn't useful. Anyone has any other ideas, besides using pg_last_error()? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PostgreSQL
On Monday 24 November 2003 10:58 am, David Kendal wrote: > Hello! I'm new to to Postgre so excuse me, but is Postgre the same as > MySQL? Yes and No. Both are databases. Both can be interfaced to php. But Under the hoods of both, are very different. For more information, http://www.mysql.com/ http://www.postgresql.org/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] RE: [PHP-DB] Re: [PHP] SQLITE
On Saturday 22 November 2003 06:43 pm, Bronislav Klucka wrote: > It's realy just "benchmark" I've done. I'm pretty much aware of system > sqlite is useing to store the data, and I also find obvious that if it > would be runnig like web database module, users will ask the same table ata > the same time (like with other db system, they are looking at the same > page) but I find it not good, I was only asking if there is a "way to > change it" You'd have better luck at getting a decent reply from the SQLite mailing list... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Strange bahavior with mysql_fetch_array($result)
On Thursday 20 November 2003 08:54 pm, Evan Panagiotopoulos wrote: > I am searching a table and have the following php code with my > comments: > > $result = mysql_query($query); > print "The result == $result"; > // it returns The result == Resource id #2" > if (!mysql_fetch_array($result)) { > ... > } else { > while ($row = mysql_fetch_array($result)) { > ... >} > } Try -> $result = mysql_query($query); // Test to see if the query failed if ($result === false) { die('some meaningful message'); } // Test to see if there are results to return if (mysql_num_rows($result) > 0) { // Get results while($row = mysql_fetch_array($result)) { } } else { echo 'No Results'; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] sybase_connect(): Sybase: "Unable to allocate connection record" problem
Dear friends, I installed sybase 12.5 develop edition, apache 2.0.48 and php 4.3.4 on the same server, the php testing is no problem. But i use function sybase_connect() in program test.php, open the file in IE, error messages : Warning: sybase_connect(): Sybase: Unable to allocate connection record in /usr/local/apache2/htdocs/test.php on line 3 I search all the internet, don't find the reason and the solution. Help, Help me. Thanks a lot. Samuel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] IBM DB2 and php
Gerard Samuel wrote: example script | // body is a text field $sql = 'select id, user_id, name, time, body, ip from NULLID.guestbook for read only'; $result = odbc_exec($db->_connection_id, $sql); odbc_longreadlen($result, 0); odbc_binmode($result, 0); // Trying to retrieve 2nd row out of 6 rows returns false when // the query contains a text field var_dump(odbc_fetch_array($result, 2)); ?>| Sorry, bad copy/paste |// body is a text field |$sql = 'select id, user_id, name, time, body, ip from NULLID.mpn_guestbook for read only'; $result = odbc_exec($mpn2_db->_db_connection_id, $sql); odbc_longreadlen($result, 0); odbc_binmode($result, 0); |// Trying to retrieve 2nd row out of 6 rows returns false when // the query contains a text field |var_dump(odbc_fetch_array($result, 2)); ?> | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] IBM DB2 and php
Maybe in early August, I got my code to work with DB2 8.1.3 via ODBC after a bit of teeth pulling. I played with it for about 2-3 weeks, and it seemed ok (slow but ok). Earlier this past week, I was modifying the DB drivers for my script, and now, DB2 refuses to cooperate. I don't remember changing any php.ini settings so Im confused as to why it doesn't work now. Im testing on w2k, php 4.3.3, db2 8.1.3 The problem revolves around field lengths being too long, because, as soon as I select a text field, the query fails, when trying to retrieve specific result rows. If anyone can shed any light on this, I would greatly appreciate it. Thanks php.ini settings ; Handling of LONG fields. Returns number of bytes to variables. 0 means ; passthru. odbc.defaultlrl = 4096 ; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. ; See the documentation on odbc_binmode and odbc_longreadlen for an explanation ; of uodbc.defaultlrl and uodbc.defaultbinmode odbc.defaultbinmode = 1 example script | // body is a text field $sql = 'select id, user_id, name, time, body, ip from NULLID.guestbook for read only'; $result = odbc_exec($db->_connection_id, $sql); odbc_longreadlen($result, 0); odbc_binmode($result, 0); // Trying to retrieve 2nd row out of 6 rows returns false when // the query contains a text field var_dump(odbc_fetch_array($result, 2)); ?>| -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: IBM DB2 & PHP 4.3.2 behaviour
Unfortunately it doesn't really work... It depends on what ODBC they happen to be running -> http://www.phpbuilder.com/mail/php-db/2001071/0395.php Thierry B. wrote: Hi, quoted from 'function.odbc-connect.php'.Perhaps it might helps: -- cs at coolspot dot de 10-Jul-2001 08:01 We've tried hard to connect from php to our IBM DB2 RS/6000 Server. It worked after we compiled with --ibm-db2= option, but it was unbelievable slow. No, just testing some options, we found out that it went from very slow (getting 100 records lasts 1 till 10 seconds) to fast access (almost same speed as with using JDBC from Servlets) to 0.2 till 0.3 seconds. We simply added the optional parameter Cursortype to odbc_connect, and with the cursortype SQL_CUR_USE_ODBC it changed in that way! Hope this helps anybody who must connect to db2 ;) ---- "Gerard Samuel" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] For the most part, I got my code running with IBM DB2 8.1.3 But its slower than dirt. Maybe 1 out of 10 times, a page would exceed the 30 second time limit. I understand on a fresh database startup, it takes time to get things together to run. But sometimes it would seem like its going fast, then othertimes, crawl slower than snails. Im just checking with the crowd that uses DB2 via PHP to see if they get similar behaviour with DB2. Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] IBM DB2 & PHP 4.3.2 behaviour
Matt Schroebel wrote: Gerard Samuel <mailto:[EMAIL PROTECTED]> wrote on Tuesday, August 19, 2003 2:32 PM: understand on a fresh database startup, it takes time to get things together to run. But sometimes it would seem like its going fast, then othertimes, crawl slower than snails. I've found that, with an AS/400, I had to build the proper indexes, such as an upper case only version for performing LIKE '%LASTNAME%' searches, *and* tell DB2 which index to use on the SELECT statement such as: SELECT MMLNAM from ADDRBOOKL2 where MMLNAM LIKE 'SAMUEL%' If I didn't point the select to the index, for some reason it wouldn't choose it. The folks at IBM Rochester Support Line told me to do this, but it seems to me that DB2 should be doing that leg work for me. It did decrease response time from 4 minutes to 5 seconds -- which is still slow. My biggest problem with it now, is that it seems it runs out of breath, every so often. It would be fairly quick, then slow down, then pick up the pace, then slow down. All this is run on a 1800XP/256M Ram Development box, where Im the only one accessing the database. I would even go as far to say that MSSQL is faster than DB2, from what Ive seen so far... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] IBM DB2 & PHP 4.3.2 behaviour
For the most part, I got my code running with IBM DB2 8.1.3 But its slower than dirt. Maybe 1 out of 10 times, a page would exceed the 30 second time limit. I understand on a fresh database startup, it takes time to get things together to run. But sometimes it would seem like its going fast, then othertimes, crawl slower than snails. Im just checking with the crowd that uses DB2 via PHP to see if they get similar behaviour with DB2. Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP/DB2
Ok, I figured out my problem. It wasn't the table names in UPPER case, but the unique id that prepended to the table names that was missing. Gerard Samuel wrote: I started playing with DB2 earlier this week. And come to find out that it creates table names/columns in UPPER case. Does anyone have any experience using DB2 in a cross platform manner, with other dbs such as MySQL? Just looking for ideas, as I've run out of them... Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DB2 and php serialized data
Gerard Samuel wrote: Most likely its not a PHP issue, but looking to see if anyone has run into this. I've inserted a serialized string, into a CLOB column. Trying to retrieve the column returns no results. If anyone has any DB2 experience, I'd be grateful if I can bounce a few questions to you offlist. Thanks for any advice/tips you may provide... I did a few more tests last night, and the problem isn't with serialized data. Im currently testing to see if a result contains returned data by issuing odbc_num_rows() The wierd thing is that if I try to select a CLOB column (this is what Im using at the moment, but I believe it applies to all LOBs), odbc_num_rows() would return -1 If I do not select a CLOB (ie INTEGER, VARCHAR this is what Im currently testing with) column, odbc_num_rows() would return the correct number of rows. I've read about odbc_num_rows() returning -1 for some databases, but that statement alludes me to believe that it either works, or doesn't work for a database. Not whether it will work for some sql conditions. So Im not sure if this is a bug or not. Im currently testing with PHP 4.3.3R2, IBM DB2 8.1 Personal Edition on win2k/IIS 5 If what Ive noticed is the expected behaviour, please let me know so I'll know whether or not to fill out a bug report... If anyone wants more information, please let me know... Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP/DB2
I started playing with DB2 earlier this week. And come to find out that it creates table names/columns in UPPER case. Does anyone have any experience using DB2 in a cross platform manner, with other dbs such as MySQL? Just looking for ideas, as I've run out of them... Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] DB2 and php serialized data
Most likely its not a PHP issue, but looking to see if anyone has run into this. I've inserted a serialized string, into a CLOB column. Trying to retrieve the column returns no results. If anyone has any DB2 experience, I'd be grateful if I can bounce a few questions to you offlist. Thanks for any advice/tips you may provide... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] ODBC Database
Larry E.Ullman wrote: Im looking at venturing into working with PHP's ODBC extention. Does anyone have any recommendations as to a Database, that is easy to understand/get into from a novice point of view, that installs on windows 2k, and is "free"? MySQL is kind of free, installs on W2K and is easy to use but it doesn't require PHP's ODBC extension since PHP already has a good MySQL extension. If you really want to use ODBC and you have MS Office, you could try Access. What Im doing is seeing if my code will run on different databases. Of which it currently runs on mySQL, PostgreSQL and MSSQL. As soon as I can get PHP5 installed Ill be checking out SQLLite. But in the meantime, Im looking for a database that would interface with ODBC. I just downloaded IBM's DB2 Personal Edition, to see what I can do there, but, Im just looking for advice etc from others who went down this road. Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] ODBC Database
Robert Twitty wrote: Unless I am mistaken, but isn't there an ODBC driver available for MySQL called MyODBC? -- bob I haven't a clue. Ill look, maybe it will help me create drivers for my DB layer, as I already know MySQL. Last night I successfully connected to IBM's DB2, but I didnt get far past that as I have to figure out, how to create tables, figure out how it likes its schemas etc, to really give it a work out... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ODBC Database
Im looking at venturing into working with PHP's ODBC extention. Does anyone have any recommendations as to a Database, that is easy to understand/get into from a novice point of view, that installs on windows 2k, and is "free"? Thanks for your suggestions. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] ODBC Database
[EMAIL PROTECTED] wrote: whoops, meant to include thishttp://www.mysql.com/downloads/api-myodbc-3.51.html Unless I am mistaken, but isn't there an ODBC driver available for MySQL called MyODBC? -- bob I haven't a clue. Ill look, maybe it will help me create drivers for my DB layer, as I already know MySQL. Last night I successfully connected to IBM's DB2, but I didnt get far past that as I have to figure out, how to create tables, figure out how it likes its schemas etc, to really give it a work out... Ok, I got the driver, and Im currently using it. Thanks. Now lets see what quirks I run into with odbc ;) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQLite
With respect to the PHP manual, are there any documentation to using this extention? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rand() Emulation
Becoming Digital wrote: Ultimately, my goal is to emulate mysql's -> SELECT * FROM TABLE ORDER BY RAND() LIMIT (X) for other databases that do not support RAND(). Which are those? Currently mySQL, PostgreSQL, and MSSQL. To me the idea above would work, but it hinges on if that rand column, doesn't have gaps. Use your table's primary key, assuming there is one. This saves creating what is otherwise unncessary data, but you'll still face "gaps" if records are deleted. Unfortunately, my primary keys are not numerical, thus the creation of a column with numerical values. Hopefully by next week, I should be ready to try out my psuedo code, and see how it plays out. If it doesn't work out, I guess no random selection happening in my code :) Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rand() Emulation
Yes its more than possible to do as you suggested, but as you implied, not very friendly, when it comes to large result sets... Roedel, Mark wrote: Might it be simpler, since you're assuming the presence of PHP anyway, to just read your entire result set into an array and then shuffle() it and then pick off the top however-many entries? Of course, that won't be very memory-efficient for particularly large data sets... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rand() Emulation
Im probably not making myself clear. Ultimately, my goal is to emulate mysql's -> SELECT * FROM TABLE ORDER BY RAND() LIMIT (X) for other databases that do not support RAND(). So using variations of php's rand(), wouldn't make sense, as it only picks one value out of a range of values, that are numerical in nature. But here is an idea, that Im thinking about, but haven't gotten to the code as yet. 1. In the tables that I want random values from, create a "rand" column, that contains incremental numerical values for each row. 2. select the the maximum number from the rand column. 3. Assume that there are no gaps between 0 and this max number. 4. Create an array of numbers with values between 0 and max number. 5. Use array_rand() to "randomly" choose (x) values from the array created in step 4. (I may choose maybe a 1 or 2 values more than whats required, just in case of gaps between 0 and max number in step 3). 6. Use these randomly choosen values to select from the database as random rows. So hopefully its a bit clearer what Im striving for. To me the idea above would work, but it hinges on if that rand column, doesn't have gaps. If you see room for improvement, or have another idea, or if Im talking gibberish then by all means. Thanks. Doug Thompson wrote: An incredible interpretation of If called without the optional min, max arguments rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15). Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rand() Emulation
Doesn't really cut it when you do not know a min and max value, or want to extract a random range of numbers. Becoming Digital wrote: Im trying to figure out a way to emulate mysql's RAND() function to be cross database compatible via php. Has anyone done anything similar to this??? How about PHP's rand() function? http://us2.php.net/manual/en/function.rand.php Edward Dudlik Becoming Digital www.becomingdigital.com Did I help you? Want to show your thanks? www.amazon.com/o/registry/EGDXEBBWTYUU -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Rand() Emulation
Im trying to figure out a way to emulate mysql's RAND() function to be cross database compatible via php. Has anyone done anything similar to this??? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Creating/Populating DB
[EMAIL PROTECTED] wrote: This should be as simple as a PHP script that opens a connection to the destination server (with rights to do all actions you mentioned).. Opens a text file with all the SQL commands you want to issue, and starts firing them off at the server 1 by 1... Once you create the database, you need to make sure: - might have to grant rights to it I believe this is the chicken & the egg trap Im falling in. If Im not mistaken, when a database is created, is the time when a user can be issued permissions to use it. Unlike mysql, the database doesn't have to exist, when granting permissions to a user. I don't think its feasable to write grant sql in the code, as it may or may not have the rights to execute as such. If Im wrong, please shoot me down, but I just may end up, that an empty database be created before hand for the installer to run on MSSQL. - change it to the current database for that connection, or disconnect and reconnect to desired database. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Creating/Populating DB
Im trying to make an install script that would run under MSSQL. I could make it either create a database or populate a database. I can't seem to do both. Has anyone been able to create and populate a MSSQL database via php in one shot?? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MSSQL Optimize?
Please forgive me for being somewhat off topic. This information is going towards a db class written in php. Does MSSQL have an SQL command counterpart to mysql's Optimize or postgresql's Vacuum?? Thanks for any insight you may provide... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Serialize...Unserialize
Hutchins, Richard wrote: I have an array of values I want to store in a MySQL db in a column called readBy of type TEXT. I want to take that array and serialize it then insert it into the db. No big deal. When I query the db and get the value from the readBy column, I know I have to unserialize it. Again, no big deal. My question about all of this is once I unserialize the data from the column, can I immediately use the array_push() function to append additional data to the unserialized data? I would imagine because the output of unserialize() is of the array type. Unless, there was an error unserializing it. Will the unserialized data immediately be recognized/treated as an array? Yes. Also, is the TEXT dolumn type an appropriate column type to store serialized data or is there another column type that should be used? If you can guarantee that the data doesn't go above 256 characters, then a varchar column can be used. But serialized data can get pretty big, so anticipate for it, by using text columns. -- Gerard Samuel http://www.trini0.org:81/ http://test1.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Unlimited Categories
Im figuring this is more of an sql question than anything else. I'm trying to figure out a table structure to create unlimited depths of categorical data. I've done something for category/subcategories before, but haven't an idea how to create categories at an unlimited depth. Any pointers would be greatly appreciated. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Users on line
I had asked on -questions about something similar to this. My concern is how would a setup like this react to a dial up user that hops ip addresses (like AOL). Would the session id remain constant, over the ip hops?? Thanks Peter Beckman wrote: Create a new table named online: id time (int unix timestamp) uid (int probably, user ID of user in question, relating to a user info table?) sessid (char 32 I think) When the user logs in, I assume you set the session. Insert a row with the current time (unix_timestamp(now()), User ID and the output of session_id() in PHP. This way you can run a query on that table at any time in one of two ways. 1. select count(id) from online where time>=(unix_timestamp(now())-900) This will give you the number of people who at least logged in in the last 15 minutes. This isn't very accurate though... so 2. If not already, put sessions in your SQL table. This way you can run a query like (and John Holmes, please feel free to clean up my joins, i suck at them): select count(*) from online,sessions where online.sessid=sessions.sessid and sessions.date>=(unix_timestamp(now())-900) This will give you the number of users who have done anything on the site in the last 15 minutes. Change the 900 to 600 or 300 for 10 or 5 minutes respectively. Every week or so you'll want to "delete from online where time>=[some number here, unix_timestamp(now()) minus how long you want to leave those entries there]". Depending on how often you want to do this and how busy your site is and how focused on performance you are, I'd advise running it once per minute and every time someone logs in, rather than once per page view, and put the values generated into a text file and read it in with readfile(). Peter On Fri, 3 Jan 2003, Bernain, Fernando G. wrote: I'm working in an app that requires to know who are "on line". When the user login the app, I use session in order to storage de name and login. Its posible to do this??? Thanks! Fernando Bernain Senior A Business Process Outsourcing KPMG Argentina Tel: 54 11 4316 5754 Fax: 54 11 4316 5734 [EMAIL PROTECTED] Email Disclaimer The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients any opinions or advice contained in this email are subject to the terms and conditions expressed in the governing KPMG client engagement letter. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ ------- -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Column Defualts
Is defaulting a column to NULL considered as a waste of space?? I have a table that has 2 columns (so far) that defualt to NULL, and potentially, there can be good amount of rows with NULL. Just wondering... -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Legal sql
Thanks for the reply. The parentheses are noted. Meantime, I did some reading and came up with this -> SELECT sc.col1 FROM search s, search_content sc WHERE s.word IN ('apache', 'mysql') AND s.wid = sc.wid Thanks for the tip. DL Neil wrote: Gerard, Im looking for another opinion on an sql statement. SELECT sc.col1 FROM search s, search_content sc WHERE s.word = 'mysql' > AND s.wid = sc.wid OR s.word = 'apache' AND s.wid = sc.wid; I had to use "s.wid = sc.wid" twice in the sql for the query to work properly. Is this the legal, correct way to do so. You're perfectly legal, but have become tangled up in the rules of operator precedence. In fact MySQL's optimiser probably takes care of it all for you. Precedence says that if there are multiple operators they will be executed from left to right, unless one is considered more important than the other, eg * precedes +, or in your case, AND precedes OR. To override precedence, or merely to help with readability, one may employ parentheses - calculations within parentheses are performed first. Thus the code becomes: WHERE ( s.word = 'mysql' AND s.wid = sc.wid ) OR ( s.word = 'apache' AND s.wid = sc.wid ); Now one can apply Boolean algebra and rationalise the apparent duplication: WHERE s.wid = sc.wid AND ( s.word = 'mysql' OR s.word = 'apache' ); As to which is 'right' and which 'wrong', let me ask: which one do you find most readable? Regards, =dn -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Legal sql
Im looking for another opinion on an sql statement. SELECT sc.col1 FROM search s, search_content sc WHERE s.word = 'mysql' AND s.wid = sc.wid OR s.word = 'apache' AND s.wid = sc.wid; I had to use "s.wid = sc.wid" twice in the sql for the query to work properly. Is this the legal, correct way to do so. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MSSQL Version
I just found out today that I could find out mysql or postgresql version # using an sql select statement. 'select version() as version' It doesn't work for MSSQL. Does anyone know of a way to retrieve MSSQL's version via php or sql statement. Thanks. -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Windows XP
Just a note for others who went through what I did, and a note of thanks. Regranting and flushing privileges, make everything run smooth for me. :) Joni Järvinen wrote: >Hi. > >Try re-GRANTing the rights for user 'crash' and after you've done that, >run 'flush PRIVILIGES'. Atleast on my winxp box it does the trick. > >-Joni- >-- >// Joni Järvinen >// [EMAIL PROTECTED] >// http://www.reactorbox.org/~wandu > >"Gerard Samuel" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > >>Please forgive me, but Im more versed in FreeBSD than winXP. >>WinXP is on my laptop for dev purposes. >>When I installed mysql, I created a database and user with the name >>'crash' via the command line client like so >>-- >>grant insert, delete, update, select, create, alter, drop on crash.* to >>crash@localhost identified by 'crash'; >>-- >> >>And as far as I know, as long as the php script has the correct database >>credentials, it should do what it needs to do. Well on my FreeBSD box >>that is. But Im not sure if additional configurations are in order for >>winXP. >> >>Any guidance would be appreciated... >>Thx >> >> >>Miles Thompson wrote: >> >> >> >>>Gerard, >>> >>>This is a shot in the dark, but does the web server (usually NOBODY, >>>but "crash" in this case? Ominous name!) have an account on the XP box >>>and the appropriate permissions to write to the MySQL database? That's >>>where I'd start, along with checking mysql_error(). >>> >>>Miles >>> >>> >>>At 04:18 PM 8/18/2002 -0400, Gerard Samuel wrote: >>> >>> >>> >>>>Im trying to solve a problem with windows xp. >>>>I have 2 identical scripts with the same db schema. One on FreeBSD >>>>running php 4.2.2/mysql 3.23.49 & the other >>>>on windows xp php 4.2.2/mysql 3.23.52. >>>> >>>>The section of the script is supposed to update a table. >>>>-- >>>>$sql = "UPDATE users SET email='$email' WHERE uid='$uid'"; >>>>$result = mysql_query($sql); >>>>var_dump($result); >>>>if (!$result) >>>>{ >>>> die(mysql_error()); >>>>} >>>>-- >>>> >>>>On the FreeBSD box, $result returns true, but returns false on the >>>>windows box. >>>>The error reported when it was false was "Access denied for user: >>>>'crash@localhost' to database 'crash'" >>>>But according to that error, the connection parameters are correct. >>>>I echoed $sql and ran the output of that in the mysql client, and it >>>>executed successfully on the windows box. >>>>So Im stuck as to what could be causing the error with the windows box. >>>> >>>>Anyone experienced this behaviour before??? >>>>Thx. >>>> >>>>-- >>>>Gerard Samuel >>>>http://www.trini0.org:81/ >>>>http://dev.trini0.org:81/ >>>> >>>> >>>> >>>>-- >>>>PHP Database Mailing List (http://www.php.net/) >>>>To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>>> >>> >>> >>> >>> >>-- >>Gerard Samuel >>http://www.trini0.org:81/ >>http://dev.trini0.org:81/ >> >> >> >> >> > > > > > -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Windows XP
Please forgive me, but Im more versed in FreeBSD than winXP. WinXP is on my laptop for dev purposes. When I installed mysql, I created a database and user with the name 'crash' via the command line client like so -- grant insert, delete, update, select, create, alter, drop on crash.* to crash@localhost identified by 'crash'; -- And as far as I know, as long as the php script has the correct database credentials, it should do what it needs to do. Well on my FreeBSD box that is. But Im not sure if additional configurations are in order for winXP. Any guidance would be appreciated... Thx Miles Thompson wrote: > Gerard, > > This is a shot in the dark, but does the web server (usually NOBODY, > but "crash" in this case? Ominous name!) have an account on the XP box > and the appropriate permissions to write to the MySQL database? That's > where I'd start, along with checking mysql_error(). > > Miles > > > At 04:18 PM 8/18/2002 -0400, Gerard Samuel wrote: > >> Im trying to solve a problem with windows xp. >> I have 2 identical scripts with the same db schema. One on FreeBSD >> running php 4.2.2/mysql 3.23.49 & the other >> on windows xp php 4.2.2/mysql 3.23.52. >> >> The section of the script is supposed to update a table. >> -- >> $sql = "UPDATE users SET email='$email' WHERE uid='$uid'"; >> $result = mysql_query($sql); >> var_dump($result); >> if (!$result) >> { >>die(mysql_error()); >> } >> -- >> >> On the FreeBSD box, $result returns true, but returns false on the >> windows box. >> The error reported when it was false was "Access denied for user: >> 'crash@localhost' to database 'crash'" >> But according to that error, the connection parameters are correct. >> I echoed $sql and ran the output of that in the mysql client, and it >> executed successfully on the windows box. >> So Im stuck as to what could be causing the error with the windows box. >> >> Anyone experienced this behaviour before??? >> Thx. >> >> -- >> Gerard Samuel >> http://www.trini0.org:81/ >> http://dev.trini0.org:81/ >> >> >> >> -- >> PHP Database Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Windows XP
Im trying to solve a problem with windows xp. I have 2 identical scripts with the same db schema. One on FreeBSD running php 4.2.2/mysql 3.23.49 & the other on windows xp php 4.2.2/mysql 3.23.52. The section of the script is supposed to update a table. -- $sql = "UPDATE users SET email='$email' WHERE uid='$uid'"; $result = mysql_query($sql); var_dump($result); if (!$result) { die(mysql_error()); } -- On the FreeBSD box, $result returns true, but returns false on the windows box. The error reported when it was false was "Access denied for user: 'crash@localhost' to database 'crash'" But according to that error, the connection parameters are correct. I echoed $sql and ran the output of that in the mysql client, and it executed successfully on the windows box. So Im stuck as to what could be causing the error with the windows box. Anyone experienced this behaviour before??? Thx. -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Benefits of assigning query to variable
Me personally, so I can echo out the variable to see if the query is making sense. Look at it as a debugging... Brian Graham wrote: >Are there any benefits to assigning a query to a variable? > > > > > -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] sql standard
Hope someone can confirm this. I was moving a mysql dump to postgresql, and I had 2 tables with MiXeD upper/lower case letters, that got converted to lowercase. I found a discussion that sql column/table/database names should be lowercase. Just trying to keep in line with a standard. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MSSQL
I just starting with mssql coming from a mysql background. Im looking for tutorials and such on how to get scripts working with php. The server is IIS 5 with php 4.2.1 and mssql 2000. phpinfo() shows that mssql is recognised. Im not sure if I have to jump through hoops like how I did when I first started with mysql in setting up users for each database with mssql. But any resources would be greatly appreciated. Meantime, Ill start with the manual and user feedback comments... Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 'htaccess" method : how to modify passwords from PHP scripts ?
Hi, Thank you to everybody who answered my question. Unfortunately, I don't use classes in my php. Here is the solution I actually used : -- -- // Generate new line for username + modified password $line = read_cgi("username").":".crypt(read_cgi("password"))."\n"; // opens a temp file $pass_file_tmp = fopen(PASS_FILE_TMP,"a"); // reads actual password file $fcontents = file(PASS_FILE); while ( list( $numero_ligne, $ligne ) = each( $fcontents ) ) { if (!ereg(read_cgi("username"),$ligne)) { fwrite($pass_file_tmp,$ligne); } } // add new password of the selected user fwrite($pass_file_tmp,$line); // deletes the old passwd file and replaced by the new one rename(PASS_FILE_TMP,PASS_FILE); -- ------ Regards, -- Samuel Torton NCSLab.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] 'htaccess" method : how to modify passwords from PHP scripts ?
Hi all, I use a Linux platform, Apache, and PHP4. I use "htaccess" method in order to have restricted accesses, and I handle my users via a PHP interface. - when I want to create a new user, I generate a string such as "username:cryptedpassword", and I insert it at the end of my ".htpasswd" file. - when I want to modify the password of an existing user, how to do that ? --> 1/ delete the line corresponding to this user, and then insert the new "username:cryptedpassword" line ? in this case, can you tell me which funtions to use (find a line in an ascii file, delete it, and insert the new one) ? --> 2/ run a command line such as "htpasswd ..." (without "-c" argument) ? in this case, can you tell me how to run a unix command line from a PHP script ? Thanks a lot in advance. Regards, -- Samuel Torton NCSLab.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Odd - Even Results in a Table - Newbie question
sorry, i made a mistake. correct with this : -- $j = 0 ; $k = 0 ; for ($i=0;$ihttp://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Odd - Even Results in a Table - Newbie question
Hi, I think you could add the following portion of code inside your request in order to get two result arrays : odd[] and even[] -- $j = 0 ; $k = 0 ; for ($i=0;$i: > HI all, > I am just a beginner at this stuff but I can't get my head around the > logic > of getting Row 1 in the left hand side of a two column table and Row 2 > data > in the right hand side. > Something like this > ___ > | Data from Row 1 in MySQL| Data from Row 2 in MySQL | > |__|| > | Data from Row 3 in MySQL| Data from Row 4 in MySQL | > ___ > > Can someone please send me some help. I know I have to do something > with > 0,2,4,6,8 and 1,3,5,7,9 but how to lay it out within the HTML is just > a > puzzle. > I am sure it has been done before. Basically I want to use it on a > Table of > Contents page > > Thanks for any help > All the Best > Lisa > > Lisa Rubanowicz > Case ITC, > Navan, Ireland > Tel: #353 (0)46 77663 > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > > -- Samuel Torton [EMAIL PROTECTED] NCSLab.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] search engine
hi there. i am currently developing an active contant engine for fully dynamic web sites (php4/mysql). now what is a db-powered site without search functionality? nothing. thus, i want to implement an internal search engine. in a nutshell, i have all my content ("pages") stored in a table. the columns "name" (unique entry title) and "body" are interesting here. now searches on a topic are no problem, i can simply perform "name LIKE .." queries. the thing is, if there are no exact matches, how can i return a virtually unlimited list of near matches, using nothing but sql queries? furthermore, i want full-text search. the bodies are blobs. is there a way to get all the items containing a string, most hits on top? what's the trick, maybe regular expressions? i am grateful for any advice of all you people who have more db experience than me. t.i.a., sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]