Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
Good idea. But I wonder whether calling the trigger each insert will loose any performance. It's going to affect things slightly but whether it'll be noticable only you can answer by testing. Another option I sometimes see is set up a replicated slave and run your reports off that instead of

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
On Thu, Mar 27, 2008 at 10:40 AM, Chris <[EMAIL PROTECTED]> wrote: > > That's never going to be fast because you're using innodb tables. > > > > Should I change it to MyISAM ones? > > > > It depends. > > Do you need or use transactions? You can't change - myisam doesn't support > them. > I ha

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
That's never going to be fast because you're using innodb tables. Should I change it to MyISAM ones? It depends. Do you need or use transactions? You can't change - myisam doesn't support them. No. That's only part of it. I have a cron job, which get the total visits often. If you

Re: [PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Shelley
On Thu, Mar 27, 2008 at 10:06 AM, Chris <[EMAIL PROTECTED]> wrote: > > Actually, I wonder how facebook is dealing with this matter. Somebody > > knows? > > > > There's lots of info here: > > http://highscalability.com/ > > about various websites (some using mysql, some using postgres, some using

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
On Thu, Mar 27, 2008 at 10:03 AM, Chris <[EMAIL PROTECTED]> wrote: > > mysql> explain select count(*) from message; > > > > ++-+-+---+---++-+--+--+-+ > > | id | select_type | table | type | possible_keys | key|

Re: [PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Chris
Actually, I wonder how facebook is dealing with this matter. Somebody knows? There's lots of info here: http://highscalability.com/ about various websites (some using mysql, some using postgres, some using oracle etc). -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Dat

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
mysql> explain select count(*) from message; ++-+-+---+---++-+--+--+-+ | id | select_type | table | type | possible_keys | key| key_len | ref | rows | Extra | ++-+-+---

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
Thank you very much, Chris. :) Fyi, On Wed, Mar 26, 2008 at 1:27 PM, Chris <[EMAIL PROTECTED]> wrote: > Shelley wrote: > > > > > +--+---+--+-+---++ > > | Field| Type | Null | Key | Default > > | Extr

[PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Shelley
Does that mean MySQL is slow? Currently one practice I am using is: get $m = $userId%256, then store $userId's information in table_$m. Then the table with more than 20, 000, 000 records is split into 256 tables, and that can speed up the query. I want to listen to your opinion about that. Actua

Re: [PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Shelley
Yes, Chris. You are right. I think I mentioned in the archive that the table is Innodb engined. Maybe Roberto didn't notice that. On Thu, Mar 27, 2008 at 7:26 AM, Chris <[EMAIL PROTECTED]> wrote: > Roberto Mansfield wrote: > > > Shelley wrote: > > > > > Hi all, > > > > > > I made a post a week ag

Fwd: Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
I did var_dump on the result resource and I got resource(5) of type (mysql result). --- Begin Message --- On Mar 26, 2008, at 12:30 PM, Evert Lammerts wrote: OK. Tried that and count comes back as 1. So your query returns only one record. Try $query ="Select answer from answers"; Why

Re: Fwd: Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Chris
Richard Dunne wrote: Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php Amaroq 09-Mar-2008 06:40 Even if an array has only one value, it is still an array and foreach will run it. The above code outputs: I'm an array. - So

Re: [PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Chris
Roberto Mansfield wrote: Shelley wrote: Hi all, I made a post a week ago to ask for the idea of the fastest way to get table records. Fyi, http://phparch.cn/index.php/mysql/35-MySQL-programming/126-fastest-way-to-get-total-records-from-a-table Hi Shelly, I question your mysql database setup

Fwd: Re: Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
Just as a aside to the list, by replying with "reply all" I was sending a reply to the original sender twice, individually and via the list with Cc so apologies to those concerned. If you want to send a reply to the sender and the list as well, then I suggest just forwarding to the list. I fou

Re: Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Jon L.
Not sure if this is relevant anymore, but... > i.e. "1223123" into ['1','2,','2','3','1,'2','3'] ? $num = "1223123"; $nums = array_filter(preg_split('//', $nums)); Or you can use this function. It's probably better since the array_filter will probably get rid of any 0's in the string. functio

Fwd: Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php Amaroq 09-Mar-2008 06:40 Even if an array has only one value, it is still an array and foreach will run it. The above code outputs: I'm an array. - So if I use: $query = "Se

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
The semi-colon is gone, although I didn't even notice it! I am using two different queries, one for count and the other to access the data itself. After running mysql_fetch_assoc, is foreach ok for accessing array members, or is there a more subtle approach? So it's working now? If it is, yo

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 5:22 pm Subject: Re: [PHP-DB] numeric string to single digit array > > > Tried that as well and got the same result. > > I tried "Select count(answer) as total from answers where > studentID=

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
Tried that as well and got the same result. I tried "Select count(answer) as total from answers where studentID='A123456789'"; from the CLI and got total = 2 as a result. So, we got rid of the Invalid Resource error and we know that the student id you use occurs in both rows in your tabl

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 4:30 pm Subject: Re: [PHP-DB] numeric string to single digit array > > > > > OK. Tried that and count comes back as 1. > > > > So your query returns only one record. Try > > $query ="Sel

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Jeremy Mcentire
On Mar 26, 2008, at 12:30 PM, Evert Lammerts wrote: OK. Tried that and count comes back as 1. So your query returns only one record. Try $query ="Select answer from answers"; Why not do a var_dump() on $result to verify that it is a mysql result resource and then verify the count of rows

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
OK. Tried that and count comes back as 1. So your query returns only one record. Try $query ="Select answer from answers"; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DB] HTML Entity Decode

2008-03-26 Thread VanBuskirk, Patricia
I found the following function at http://us.php.net/html_entity_decode.  This looks exactly like what I need to filter out information in a text field that's been copied from Word.  The "endash" or "–" is not being accepted and my processing page is halting.  My question to you is where in my pa

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 4:04 pm Subject: Re: [PHP-DB] numeric string to single digit array > > > This is my code. The only error is at line 15 as I stated above. > > > > 1 > 2 DEFINE ("host","localhost"); > > 3 DEFI

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Jason Gerfen
Evert Lammerts wrote: > >> This is my code. The only error is at line 15 as I stated above. >> >> 1 > 2 DEFINE ("host","localhost"); >> 3 DEFINE ("user","root"); >> 4 DEFINE ("password","password"); >> 5 DEFINE ("database","questions"); >> 6 >> 7 $connection=mysql_connect(host,user,password) or d

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
This is my code. The only error is at line 15 as I stated above. 1 Turn line 13 into $result = mysql_query($query) or die(mysql_error()); , so leave out the connection parameter and append the die() function, and see what error that produces. -- PHP Database Mailing List (http://www.

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 3:39 pm Subject: Re: [PHP-DB] numeric string to single digit array > > > PHP is telling me that the resource I am using for > mysql_fetch_assoc is invalid: > > > > $query ="Select answer from

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
PHP is telling me that the resource I am using for mysql_fetch_assoc is invalid: $query ="Select answer from answers where studentID ='A123456789'"; $result = mysql_query($query,$connection); $count=0; while($row = mysql_fetch_assoc($result)); { $count++; } echo $count; Are you sure your d

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Evert Lammerts <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 3:12 pm Subject: Re: [PHP-DB] numeric string to single digit array > > > I ran this > > > > $query ="Select answer from answers where studentID ='A123456789'"; > > $result = mysql_query($query,

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Evert Lammerts
I ran this $query ="Select answer from answers where studentID ='A123456789'"; $result = mysql_query($query,$connection); $resultArray = str_split($result,1); $count = count($resultArray); Where's the fetch? |$result = mysql_query("SELECT answer FROM answers WHERE studentID = 'A123456789

Re: [PHP-DB] numeric string to single digit array

2008-03-26 Thread Richard Dunne
- Original Message - From: Chris <[EMAIL PROTECTED]> Date: Wednesday, March 26, 2008 2:18 am Subject: Re: [PHP-DB] numeric string to single digit array > Richard Dunne wrote: > > Sorry for the top-posting, it's my mail client, not my design. > I honestly have not even looked at myphpadmi

[PHP-DB] Re: Table optimization ideas needed

2008-03-26 Thread Roberto Mansfield
Shelley wrote: > Hi all, > > I made a post a week ago to ask for the idea of the fastest way to get > table records. > Fyi, > http://phparch.cn/index.php/mysql/35-MySQL-programming/126-fastest-way-to-get-total-records-from-a-table > Hi Shelly, I question your mysql database setup. I have a log