Re: [PHP-DB] PDO user question
That's how I'd do it. Extend the PDO interface on your abstract class to include a num_rows() method that utilizes that higher level count($this-result). It might be a little more overhead... but RAM is cheap... and there's always forking/extending the library in C/C++... -Brandon On 2012-09-09 11:49, Michael Stowe wrote: How are you using the number? Probably the easiest way is to utilize PDOStatement::FetchAll() and then do a count() on that result set. - Mike Sent from my iPhone On Sep 9, 2012, at 11:42 AM, Stefan Wixfort stefan.wixf...@gmx.de wrote: Hi Jim I've had some success with querying using pdo and prepared statements as well. One thing that I'm curious about is How does one handle the need to get the number of rows returned by a Select? The documentation is very clear that PDO doesn't return that value for a Select statement (depending upon driver?) and there were a couple of solutions that made no sense to me. There was even one that did a completely separate query just to get the row count which makes even less sense. I believe you are referring to SELECT COUNT(*)... Because I couldn't find a different way I use that. -- 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] Sqlite inserts inside a PDO fetch loop
Hello, I have a situation where I am trying to create an index of words contained in a particular table. The table is about 9,400 rows, and the index ends up being 1,500,000 words (rows). While creating the index, I do a select of the table, and extract the words. I cache these word results into an array, and use that array for a prepared insert statement into the word index table. My problem is memory. It maxes out at about 35 MB. This is a bit high, and what I would like to do is do an onset transaction when the array reaches a certain size, like 10,000, then unset the array and continue. The problem with that is I cannot commit the insert while the fetch statement is still pending. I have tried fetchAll instead, but still have similar memory issues. I have also tried to commit the inserts at the end, but that causes Sqlite to hog the memory. Is there any way to fix this, or is this just the cost of doing business with Sqlite? Thanks! B -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_prepare()/pg_execute() and pg_query_params()
d == danak...@gmail.com writes: d Then you should put some debugging around the connection code. d |$pgconn = pg_connect(host=localhost port=5432 dbname=test user=test d password=test)| or die(Problem with connection to PostgreSQL: d .pg_last_error()); d So you can be sure that you are really connected. Also you can use d pg_result_error()... d $result = pg_query_params($pgconn, $update, array($foo, $bar)); d echo pg_result_error($result); d or even pg_result_error_field(). I did have error checking around the call to pg_connect(). My problem was twofold. One, I had a typo in the connection string and two, I wasn't properly passing the error message back to top level application, so I wasn't seeing the error from pg_connect(). Stupid mistake. -- Brandon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] pg_prepare()/pg_execute() and pg_query_params()
I'm fairly new to PHP but have a great deal of Perl experience for what it's worth. I'm having a problem where if I try to use a parameterized query it fails but pg_last_error() returns nothing. For example, $result = pg_query_params($pgconn, $update, array($foo, $bar)); if (! $result) { fwrite($fp, before); fwrite($fp, pg_last_error()); fwrite($fp, after); } The strings before and after are showing up in $fp, but nothing from pg_last_error(). Similarly, if I use pg_prepare() and pg_execute(), pg_prepare() fails but nothing is returned from pg_last_error(). Using pg_query() works, but I need to parameterize the SQL. The versions I'm using are $ php --version PHP 5.2.4-2ubuntu5.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb 11 2009 20:09:52) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies and PostgreSQL 8.3.6. What am I missing? -- Brandon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_prepare()/pg_execute() and pg_query_params()
b == bran...@geronimoalloys.com writes: b I'm fairly new to PHP but have a great deal of Perl experience for b what it's worth. I'm having a problem where if I try to use a b parameterized query it fails but pg_last_error() returns nothing. For b example, b $result = pg_query_params($pgconn, $update, array($foo, $bar)); b if (! $result) { b fwrite($fp, before); b fwrite($fp, pg_last_error()); b fwrite($fp, after); b } I should also mentioned with log_statement = 'all' in postgresql.conf, nothing is dumped to the logs. This tells me pg_query_params() isn't passing anything to the postgres server. -- Brandon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help With Inventory Listings
Can anyone help me figure out how to solve my inventory listing problem? I am using php_5 and mysql_5.0 w/apache on fbsd. I need to figure out a way to make a subtitle for every category (genre) in the inventory so when I list the entire inventory on a sheet (at client's request), it is organized by category (genre) and each category (genre) has a title line above it. So the there is not just one big list rather a neat list with titles for each category THEN all the rows in that category etc. I can't figure out the loop to make the titles. I have them sorted as you can by genre, the list is formatted fine There are alternating colors on the rows to make it read easier. I just want to keep from having to make a statement for EACH genre. I will eventually make the genre list dynamic too, so I need to figure out how to dynamically generate this inventory list. This is the output I have now: DVD ID TITLE GENRE 1 GENRE 2 GENRE 3ACT QTY BCK HLDINC OG USR OUT DATE OUT USRIN DATE IN USR CY 20860003Movie name action 1 1 0 1000-00-00 00:00:00 -00-00 00:00:000 20860020Move Name COMEDY 11 0 1000 -00-00 00:00:00 -00-00 00:00:00 0 20860006Movie name COMEDY 1 1 0 1000-00-00 00:00:00 -00-00 00:00:000 What I WANT to see is: I will fix the background colors, I just want to see the GENRE: ACTION - 1 TITLES and GENRE: COMEDY - 2 TITLES DVD ID TITLE GENRE 1 GENRE 2 GENRE 3ACT QTY BCK HLDINC OG USR OUT DATE OUT USRIN DATE IN USR CY GENRE: ACTION - 1 TITLES 20860003Movie name ACTION 1 1 0 1000-00-00 00:00:00 -00-00 00:00:000 GENRE: COMEDY - 2 TITLES 20860023Movie name COMEDY1 1 0 1000 -00-00 00:00:00-00-00 00:00:00 0 20860006Movie name COMEDY 1 1 0 1000-00-00 00:00:00 -00-00 00:00:000 This is the code: 1. function invlistONE(){ 2. dbconnect('connect'); 3. $invlist = mysql_query(SELECT * FROM sp_dvd ORDER BY dvdGenre); 4. 5. 6. ? 7. table cellspacing=0 style=font-size:8pt; 8. tr 9. div style=font-size:8pt 10. td align=left class=bodybDVD ID/b/td 11. td align=left width=225bTITLE/b/td 12. td align=left class=body width=75bGENRE 1/b/td 13. td align=left width=75bGENRE 2/b/td 14. td align=left class=body width=75bGENRE 3/b/td 15. td align=left width=10bACT/b/td 16. td align=left class=body width=10bQTY/b/td 17. td align=left width=10bBCK/b/td 18. td align=left class=body width=10bHLD/b/td 19. td align=left width=10bINC/b/td 20. td align=left class=body width=50bOG USR/b/td 21. td align=leftbOUT DATE/b/td 22. td align=left class=body width=55bOUT USR/b/td 23. td align=leftbIN DATE/b/td 24. td align=left class=body width=50bIN USR/b/td 25. td align=left width=\10\bCY/b/td 26. /div 27. /tr 28. ? 29. 30. $count = 0; 31. while($row = mysql_fetch_array($invlist)){ 32. 33. $dvdId = $row['dvdId']; 34. $dvdGenre = $row['dvdGenre']; 35. $dvdGenre2 = $row['dvdGenre2']; 36. $dvdGenre3 = $row['dvdGenre3']; 37. $dvdTitle = $row['dvdTitle']; 38. $dvdOnHand = $row['dvdOnHand']; 39. $dvdOnHand = $row['dvdOnHand']; 40. 41. $active = $row['dvdActive']; 42. $back = $row['backordered']; 43. $hold = $row['dvdHoldRequests']; 44. $incoming = $row['incomingInventory']; 45. 46. $ogUserId = $row['ogUserId']; 47. $outDate = $row['outDate']; 48. $outUserId = $row['outUserId']; 49. $inDate = $row['inDate']; 50. $inUserId = $row['inUserId']; 51. $cycles = $row['cycles']; 52. $dvdLastUpdate = $row['dvdLastUpdate']; 53. $dvdLastAdminUpdate = $row['dvdLastAdminUpdate']; 54. 55. if ( $count == 1 ) { echo (tr bgcolor=\#c1c1c1\); } 56. else { echo (tr);} 57. 58. echo (div ); 59. echo (td class=\body\ align=\left\ $dvdId /td); 60. echo (td align=\left\ width=\225\$dvdTitle/td); 61. echo (td class=\body\ align=\left\ width=\75\$dvdGenre/td); 62. echo (td align=\left\ width=\75\$dvdGenre2/td); 63. echo (td class=\body\ align=\left\ width=\75\$dvdGenre3/td); 64. echo (td align=\left\ width=\10\$active/td); 65. echo (td class=\body\ align=\left\ width=\10\$dvdOnHand/td); 66. echo (td align=\left\ width=\10\$back/td); 67. echo (td class=\body\ align=\left\ width=\10\$hold/td); 68. echo (td align=\left\ width=\10\$incoming/td); 69. echo (td class=\body\ align=\left\ width=\50\$ogUserId/td); 70. echo (td align=\left\ width=\75\$outDate/td); 71. echo
[PHP-DB] Insert Newbie
Below is the code I used to try to insert info into a mysql database, the form posts to itself. After I hit the submit button it isn't echoing the indication that information has been added, and when I check the database there isn't anything there. help please! ? $usr = username; $pwd = password; $db = dbname; $host = localhost; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo(ERROR: . mysql_error() . \n);} ? HTML HEAD TITLEInsert Link/TITLE /HEAD BODY BGCOLOR=#FF PFONT SIZE=5B Add Link /B /FONT/P ? if ($REQUEST_METHOD==POST) { $description = str_replace(','',$description); $sitename = str_replace(','',$sitename); $SQL = INSERT INTO links ; $SQL = $SQL . (category, sitename, siteurl, description) VALUES ; $SQL = $SQL . ('$category', '$sitename','$siteurl','$description') ; $result = mysql_db_query($db,$SQL,$cid); if (!$result) { echo(ERROR: . mysql_error() . $SQL\n);} echo (PBNew Link Added/B/P\n); } ? FORM NAME=fa ACTION=insert.php METHOD=POST TABLE TRTDBCategory: /B /TDTDINPUT TYPE=text NAME=category SIZE=40/TD/TR TRTDBSite Name:/B /TDTDINPUT TYPE=text NAME=sitename SIZE=40/TD/TR TRTDBSite URL: /B /TDTDINPUT TYPE=text NAME=siteurl VALUE=http://; SIZE=40/TD/TR TRTD VALIGN=TOPBDescription: /B /TDTD TEXTAREA NAME=description ROWS=5 COLS=40/TEXTAREA/TD/TR TRTH COLSPAN=2PINPUT TYPE=submit VALUE=Add Link/P/TH/TR /TABLE /FORM ?mysql_close($cid); ? /BODY /HTML -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date of Birth From Form
Hey all, I have a credit application form, and one of the required elements is the applicant's Date of Birth. I have creditapp table with a birthdate field and it is a DATE datatype. On the form, I want to be able to have them enter their Date of Birth as mm/dd/ and have it go into the database properly (-mm-dd). Is there a way to do it this way, or am I going about it wrong? Any help would be greatly appreciated. Thanks! Brandon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Upload Multiple Images
Hi all...kinda new to PHP and MySQL...anyhow, I have created the following table: CREATE TABLE images ( id smallint(6) NOT NULL auto_increment, image_title varchar(75) default NULL, image_src varchar(150) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; I have also created a form that allows me to upload one image at a time, but I would like to be able to upload SEVERAL images at once. Directory for images is: ./_images/(filenames) There are also some subdirectories. What can I do to make it so that I can upload all of the images in a directory (or at least more than one) without having to type each one in and submit it? Your help would be very much appreciated! Thanks, Brandon Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] members page
im making a webdesign website that has a members login, do i have to make a member page for each member or can i get the info from the database of the person whom logged in and put it on the members page -- 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
Can some one tell me how i would make a search engine, like what talbes and how many fields and what the form should look like -- 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]