Re: Number of Lines in Table.
| From: | Karl DeSaulniers | Date: | Wed, 03 Sep 2014 05:13:57 +0000 |
| Subject: | Re: Number of Lines in Table. | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48917@lists.php.net to get a copy of this message | ||
I see. Ok thanks Matt. Will look into that if I start working with those size databases.
My apology Ethan, wasn't aware of the scope.
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
On Sep 3, 2014, at 12:09 AM, Matt Pelmear <mjpelmear@gmail.com> wrote:
> Karl,
>
> This works for small datasets, but when you have a large amount of data (either in terms of
> storage or row count) it is no longer practical.
> This is why people typically use the SQL row count instead of transferring all of the data to
> php and doing the work there. It is much more efficient.
> (You may wish to read about buffered vs unbuffered queries)
>
> Matt
>
> On Sep 2, 2014 9:57 PM, "Karl DeSaulniers" <karl@designdrumm.com> wrote:
> On Sep 2, 2014, at 9:37 PM, Ethan Rosenberg <erosenberg@hygeiabiomedical.com> wrote:
>
> > Dear List -
> >
> > This works:
> >
> > mysql> describe Purchases;
> > +-------+-------------+------+-----+---------+----------------+
> > | Field | Type | Null | Key | Default | Extra |
> > +-------+-------------+------+-----+---------+----------------+
> > | indx | smallint(6) | NO | PRI | NULL | auto_increment |
> > | manf | varchar(20) | YES | | NULL | |
> > | itm | varchar(50) | YES | | NULL | |
> > | prc | float | YES | | NULL | |
> > +-------+-------------+------+-----+---------+----------------+
> > 4 rows in set (0.00 sec)
> >
> > What is my error?
> >
> > TIA
> >
> > Ethan
>
> Hi Ethan,
> Is it terribly important for you to get the count from MySQL?
> Php does a nice job of this very easily.
>
> $sql = "SELECT itm FROM Purchases";
>
> $result = mysqli_query($cxn, $sql);
>
> if (!mysqli_query($cxn, $sql27))
> printf("Errormessage: %s\n", mysqli_error($cxn));
>
> if(!$result || (mysql_numrows($result) < 1)){
> return NULL;
> }
> /* Return result array */
> $rowarray = mysqli_fetch_array($result);
> $numrows = count($rowarray);
>
> //return $rowarray;
>
> print_r('Number of rows: '.$numrows);
> print_r('Results { '.$row.' }');
>
> Haven't tested this, but I believe it should work out the box. May need to tweek to taste.
> HTH,
>
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>