php-general Digest 24 Nov 2009 14:56:37 -0000 Issue 6458

Topics (messages 300044 through 300060):

Re: function not returning query
        300044 by: Philip Thompson
        300046 by: Allen McCabe
        300047 by: Ashley Sheridan
        300048 by: Ashley Sheridan

Re: Query based on Server offset TimeStamp
        300045 by: Philip Thompson

Metadata - mysqli
        300049 by: keyser soze
        300050 by: David Otton
        300052 by: keyser soze

Re: My experience with the "Forms Generation and Validation" class
        300051 by: Martin Scotta

dbase_get_record_with_names; Very slow search!!!
        300053 by: Rahul S. Johari
        300054 by: Ashley Sheridan
        300055 by: Rahul S. Johari
        300057 by: keyser soze
        300059 by: Rahul S. Johari
        300060 by: keyser soze

Re: PHP and XML
        300056 by: Juan

Question about includes
        300058 by: Al

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:

> Hi, thanks for reading, I hope you can help:
> 
> In my main file for an orders page I have the following code:
> 
> 
> if (isset($_GET['filterby']))
> {
>  $resultOrders = adminFilterQuery();
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }
> else
> {
>  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> die(mysql_error("Could not query the database!"));
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }

You reduce this part by one line by putting the following after the else 
statement and removing the other 2:

$numberOfOrders = mysql_num_rows ($resultOrders);

Also, these queries don't need a semi-colon (;) to end the query. PHP handles 
this part. Remove them.


> adminFilterQuery() is a custom function that is supposed to return a
> mysql_query, here are the last few lines of this function:
> 
> 
> $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> {$order_by_param};";
> $result = mysql_query($query);
> return $result;
> 
> l am getting this error when I try to filter my query using a form in tandem
> with the quey building function:
> 
> *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource
> 
> where the line is the one where I use the mysql_num_rows function.
> 
> What am I missing here?
> 
> Thanks!

Do you get this warning with both queries? Make sure that your queries are 
using a valid mysql connection. You may also consider using a database class to 
perform the repetitive tasks so that you really only have to be concerned with 
the queries you're writing...?

<?php
class database {
    public function query ($sql) {
        $result = mysql_query ($sql);
        if ($result === false) {
            die ('Uh oh!');
        }
        return $result;
    }
    
    public function numRows ($result) {
        return mysql_num_rows ($result);
    }
}
$db = new database();
$result = $db->query('SELECT * FROM afy_order');
$numRows = $db->numRows($result);
?>

Of course this is just a simple example, but you get the idea. Hope that stirs 
your brain!

~Philip

--- End Message ---
--- Begin Message ---
Okay, suddenly I got it to filter the results, but I still can't figure out
where this part of the query is coming from, at the end of the query string
in the URL, I have this "filter.x=0&filter.y=0".

No where in my form do I have a field named filter.x or filter.y. I DO
however, have 3 forms (I don't want to mess with AJAX), my set up looks like
this:

Filter by:
User - [username dropdown  v] Order by [database fields  v] Asc/Desc
[Ascend  v] - Go
School - [school dropdown  v] Order by [database fields  v] Asc/Desc
[Ascend  v] - Go
Show - [show dropdown  v] Order by [database fields  v] Asc/Desc [Ascend  v]
- Go

There are actually two order by fields, but this gives you the idea. Each of
the three lines is a separate form, each with a unique name all with a "get"
method, but all three Go buttons are named "filter", I didn't think to try
changing it until now, but is this perhaps where the filter.x and filter.y
are coming from? I have never seen this before in a query.

Oh, now the filter that was working spontaneously gives me the error I have
been getting all along, this is so frustrating.

To those who asked, yes I am connected to the database; I forgot to mention
that the else part of my if statement works, as long as I don't try to
filter my results it works.

Here is an example of the URL that my filter function (via one of the 3
forms) outputs:
http://lpacmarketing.hostzi.com/afy/orders/default.php?filterby=school&schoolid=36&orderby1=order_id&asc_desc_order1=Descend&orderby2=pmt_recd_date&asc_desc_order2=Descend&filter.x=13&filter.y=8&filter=Go

On Mon, Nov 23, 2009 at 8:03 PM, Philip Thompson <philthath...@gmail.com>wrote:

> On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:
>
> > Hi, thanks for reading, I hope you can help:
> >
> > In my main file for an orders page I have the following code:
> >
> >
> > if (isset($_GET['filterby']))
> > {
> >  $resultOrders = adminFilterQuery();
> >  $numberOfOrders = mysql_num_rows($resultOrders);
> > }
> > else
> > {
> >  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> > die(mysql_error("Could not query the database!"));
> >  $numberOfOrders = mysql_num_rows($resultOrders);
> > }
>
> You reduce this part by one line by putting the following after the else
> statement and removing the other 2:
>
> $numberOfOrders = mysql_num_rows ($resultOrders);
>
> Also, these queries don't need a semi-colon (;) to end the query. PHP
> handles this part. Remove them.
>
>
> > adminFilterQuery() is a custom function that is supposed to return a
> > mysql_query, here are the last few lines of this function:
> >
> >
> > $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> > {$order_by_param};";
> > $result = mysql_query($query);
> > return $result;
> >
> > l am getting this error when I try to filter my query using a form in
> tandem
> > with the quey building function:
> >
> > *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL
> result
> > resource
> >
> > where the line is the one where I use the mysql_num_rows function.
> >
> > What am I missing here?
> >
> > Thanks!
>
> Do you get this warning with both queries? Make sure that your queries are
> using a valid mysql connection. You may also consider using a database class
> to perform the repetitive tasks so that you really only have to be concerned
> with the queries you're writing...?
>
> <?php
> class database {
>    public function query ($sql) {
>        $result = mysql_query ($sql);
>        if ($result === false) {
>            die ('Uh oh!');
>        }
>        return $result;
>    }
>
>    public function numRows ($result) {
>        return mysql_num_rows ($result);
>    }
> }
> $db = new database();
> $result = $db->query('SELECT * FROM afy_order');
> $numRows = $db->numRows($result);
> ?>
>
> Of course this is just a simple example, but you get the idea. Hope that
> stirs your brain!
>
> ~Philip

--- End Message ---
--- Begin Message ---
On Mon, 2009-11-23 at 21:53 -0800, Allen McCabe wrote:

> Okay, suddenly I got it to filter the results, but I still can't figure out
> where this part of the query is coming from, at the end of the query string
> in the URL, I have this "filter.x=0&filter.y=0".
> 
> No where in my form do I have a field named filter.x or filter.y. I DO
> however, have 3 forms (I don't want to mess with AJAX), my set up looks like
> this:
> 
> Filter by:
> User - [username dropdown  v] Order by [database fields  v] Asc/Desc
> [Ascend  v] - Go
> School - [school dropdown  v] Order by [database fields  v] Asc/Desc
> [Ascend  v] - Go
> Show - [show dropdown  v] Order by [database fields  v] Asc/Desc [Ascend  v]
> - Go
> 
> There are actually two order by fields, but this gives you the idea. Each of
> the three lines is a separate form, each with a unique name all with a "get"
> method, but all three Go buttons are named "filter", I didn't think to try
> changing it until now, but is this perhaps where the filter.x and filter.y
> are coming from? I have never seen this before in a query.
> 
> Oh, now the filter that was working spontaneously gives me the error I have
> been getting all along, this is so frustrating.
> 
> To those who asked, yes I am connected to the database; I forgot to mention
> that the else part of my if statement works, as long as I don't try to
> filter my results it works.
> 
> Here is an example of the URL that my filter function (via one of the 3
> forms) outputs:
> http://lpacmarketing.hostzi.com/afy/orders/default.php?filterby=school&schoolid=36&orderby1=order_id&asc_desc_order1=Descend&orderby2=pmt_recd_date&asc_desc_order2=Descend&filter.x=13&filter.y=8&filter=Go
> 
> On Mon, Nov 23, 2009 at 8:03 PM, Philip Thompson 
> <philthath...@gmail.com>wrote:
> 
> > On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:
> >
> > > Hi, thanks for reading, I hope you can help:
> > >
> > > In my main file for an orders page I have the following code:
> > >
> > >
> > > if (isset($_GET['filterby']))
> > > {
> > >  $resultOrders = adminFilterQuery();
> > >  $numberOfOrders = mysql_num_rows($resultOrders);
> > > }
> > > else
> > > {
> > >  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> > > die(mysql_error("Could not query the database!"));
> > >  $numberOfOrders = mysql_num_rows($resultOrders);
> > > }
> >
> > You reduce this part by one line by putting the following after the else
> > statement and removing the other 2:
> >
> > $numberOfOrders = mysql_num_rows ($resultOrders);
> >
> > Also, these queries don't need a semi-colon (;) to end the query. PHP
> > handles this part. Remove them.
> >
> >
> > > adminFilterQuery() is a custom function that is supposed to return a
> > > mysql_query, here are the last few lines of this function:
> > >
> > >
> > > $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> > > {$order_by_param};";
> > > $result = mysql_query($query);
> > > return $result;
> > >
> > > l am getting this error when I try to filter my query using a form in
> > tandem
> > > with the quey building function:
> > >
> > > *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL
> > result
> > > resource
> > >
> > > where the line is the one where I use the mysql_num_rows function.
> > >
> > > What am I missing here?
> > >
> > > Thanks!
> >
> > Do you get this warning with both queries? Make sure that your queries are
> > using a valid mysql connection. You may also consider using a database class
> > to perform the repetitive tasks so that you really only have to be concerned
> > with the queries you're writing...?
> >
> > <?php
> > class database {
> >    public function query ($sql) {
> >        $result = mysql_query ($sql);
> >        if ($result === false) {
> >            die ('Uh oh!');
> >        }
> >        return $result;
> >    }
> >
> >    public function numRows ($result) {
> >        return mysql_num_rows ($result);
> >    }
> > }
> > $db = new database();
> > $result = $db->query('SELECT * FROM afy_order');
> > $numRows = $db->numRows($result);
> > ?>
> >
> > Of course this is just a simple example, but you get the idea. Hope that
> > stirs your brain!
> >
> > ~Philip


My guess would be that you're submitting the form using an image button,
which would send the x and y coordinates of the click within the button.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Tue, 2009-11-24 at 02:11 -0800, Allen McCabe wrote:

> I am! Will these extra query variables cause any problems or should I
> use standard submit inputs?
> 
> Thanks Ashley!
> 
> 
> On Tue, Nov 24, 2009 at 1:10 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> 
>         
>         On Mon, 2009-11-23 at 21:53 -0800, Allen McCabe wrote: 
>         
>         > Okay, suddenly I got it to filter the results, but I still can't 
> figure out
>         > where this part of the query is coming from, at the end of the 
> query string
>         > in the URL, I have this "filter.x=0&filter.y=0".
>         > 
>         > No where in my form do I have a field named filter.x or filter.y. I 
> DO
>         > however, have 3 forms (I don't want to mess with AJAX), my set up 
> looks like
>         > this:
>         > 
>         > Filter by:
>         > User - [username dropdown  v] Order by [database fields  v] Asc/Desc
>         > [Ascend  v] - Go
>         > School - [school dropdown  v] Order by [database fields  v] Asc/Desc
>         > [Ascend  v] - Go
>         > Show - [show dropdown  v] Order by [database fields  v] Asc/Desc 
> [Ascend  v]
>         > - Go
>         > 
>         > There are actually two order by fields, but this gives you the 
> idea. Each of
>         > the three lines is a separate form, each with a unique name all 
> with a "get"
>         > method, but all three Go buttons are named "filter", I didn't think 
> to try
>         > changing it until now, but is this perhaps where the filter.x and 
> filter.y
>         > are coming from? I have never seen this before in a query.
>         > 
>         > Oh, now the filter that was working spontaneously gives me the 
> error I have
>         > been getting all along, this is so frustrating.
>         > 
>         > To those who asked, yes I am connected to the database; I forgot to 
> mention
>         > that the else part of my if statement works, as long as I don't try 
> to
>         > filter my results it works.
>         > 
>         > Here is an example of the URL that my filter function (via one of 
> the 3
>         > forms) outputs:
>         > 
> http://lpacmarketing.hostzi.com/afy/orders/default.php?filterby=school&schoolid=36&orderby1=order_id&asc_desc_order1=Descend&orderby2=pmt_recd_date&asc_desc_order2=Descend&filter.x=13&filter.y=8&filter=Go
>         > 
>         > On Mon, Nov 23, 2009 at 8:03 PM, Philip Thompson 
> <philthath...@gmail.com>wrote:
>         > 
>         > > On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:
>         > >
>         > > > Hi, thanks for reading, I hope you can help:
>         > > >
>         > > > In my main file for an orders page I have the following code:
>         > > >
>         > > >
>         > > > if (isset($_GET['filterby']))
>         > > > {
>         > > >  $resultOrders = adminFilterQuery();
>         > > >  $numberOfOrders = mysql_num_rows($resultOrders);
>         > > > }
>         > > > else
>         > > > {
>         > > >  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
>         > > > die(mysql_error("Could not query the database!"));
>         > > >  $numberOfOrders = mysql_num_rows($resultOrders);
>         > > > }
>         > >
>         > > You reduce this part by one line by putting the following after 
> the else
>         > > statement and removing the other 2:
>         > >
>         > > $numberOfOrders = mysql_num_rows ($resultOrders);
>         > >
>         > > Also, these queries don't need a semi-colon (;) to end the query. 
> PHP
>         > > handles this part. Remove them.
>         > >
>         > >
>         > > > adminFilterQuery() is a custom function that is supposed to 
> return a
>         > > > mysql_query, here are the last few lines of this function:
>         > > >
>         > > >
>         > > > $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' 
> ORDER BY
>         > > > {$order_by_param};";
>         > > > $result = mysql_query($query);
>         > > > return $result;
>         > > >
>         > > > l am getting this error when I try to filter my query using a 
> form in
>         > > tandem
>         > > > with the quey building function:
>         > > >
>         > > > *Warning*: mysql_num_rows(): supplied argument is not a valid 
> MySQL
>         > > result
>         > > > resource
>         > > >
>         > > > where the line is the one where I use the mysql_num_rows 
> function.
>         > > >
>         > > > What am I missing here?
>         > > >
>         > > > Thanks!
>         > >
>         > > Do you get this warning with both queries? Make sure that your 
> queries are
>         > > using a valid mysql connection. You may also consider using a 
> database class
>         > > to perform the repetitive tasks so that you really only have to 
> be concerned
>         > > with the queries you're writing...?
>         > >
>         > > <?php
>         > > class database {
>         > >    public function query ($sql) {
>         > >        $result = mysql_query ($sql);
>         > >        if ($result === false) {
>         > >            die ('Uh oh!');
>         > >        }
>         > >        return $result;
>         > >    }
>         > >
>         > >    public function numRows ($result) {
>         > >        return mysql_num_rows ($result);
>         > >    }
>         > > }
>         > > $db = new database();
>         > > $result = $db->query('SELECT * FROM afy_order');
>         > > $numRows = $db->numRows($result);
>         > > ?>
>         > >
>         > > Of course this is just a simple example, but you get the idea. 
> Hope that
>         > > stirs your brain!
>         > >
>         > > ~Philip
>         
>         
>         
>         
>         My guess would be that you're submitting the form using an
>         image button, which would send the x and y coordinates of the
>         click within the button.
>         
>         Thanks,
>         Ash
>         http://www.ashleysheridan.co.uk
>         
>         
>         
> 
> 


The only time they'll cause a problem is if you use some sort of loop to
translate all the form inputs into something that is used in your code.
For example, if you looped through all the form inputs to create your
filter, regardless of what the inputs were called, then you would be
running into all sorts of problems.

This is not something you should try and 'fix' on the client-side but
the server side, as everything that comes from the client is not to be
trusted, ever!

Saying that though, I have seen some systems (HSBC payment system)
reject inputs containing x and y coordinates from image buttons and
cause the whole form to fail. In your case that won't happen, but it's
something to keep in mind in the future maybe?

If you want to change the button, you could use a regular submit button
and style it up with css:

#submit_button_id
{
    border: 0px none;
    background-image: url('button.png');
    background-repeat: no-repeat;
    width: 100px;
    height: 25px;
}

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Nov 23, 2009, at 7:37 PM, Don Wieland wrote:

> Hello,
> 
> I have a mySQL database server in Florida USA (EST) and I want to do a query 
> on a record in California, USA (PST) 3 hours earlier using PST instead of EST.
> 
> I would like to add to my CORE page that offset of the timezone so I can use 
> it in a query like:
> 
> Select * FROM aTable WHERE ServerOffsetTimeStap >= Row_Start_TimeStamp AND 
> ServerOffsetTimeStap <= Row_End_TimeStamp
> 
> How would I do this?
> 
> Appreciate any help you can offer. Thanks!

When I store timestamps, I store them in GMT time. This way, no matter when you 
pull it out of the database, you *know* when it was stored - even in a 
different timezone. To achieve this...

<?php
// Put this into the database
$timeIntoDb = time() - date("Z");

// Pull this from the database
$ts = $timeFromDb + date("Z");
?>

Maybe this will make it a little easier to query accordingly...? Hope this 
stirs your brain.

~Philip

PS... Others may profess that you use UTC instead of GMT, but that's a 
different thread.

--- End Message ---
--- Begin Message ---
hi
mysqli_fetch_field provide result metadata
like 'column name', 'max length', 'datatype' etc
but i need the "comment" of each column

is this possible?

(i guess it does't because
i do a query, and that query brings to me columns and its values
but not the comment metadata...
but it would be very nice to have the "field comment" metadata
in order to use it on interfaces or reports, etc)

thanks


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091123-1, 23/11/2009
Tested on: 24/11/2009 09:01:48 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--- End Message ---
--- Begin Message ---
2009/11/24 keyser soze <bajopala...@yahoo.com.ar>:

> mysqli_fetch_field provide result metadata
> like 'column name', 'max length', 'datatype' etc
> but i need the "comment" of each column
>
> is this possible?

The table that stores data about columns is
information_schema.COLUMNS. You're looking for the COLUMN_COMMENT
column. Eg

SELECT COLUMN_COMMENT FROM information_schema.COLUMNS WHERE
TABLE_SCHEMA = 'database' AND TABLE_NAME = 'table' AND COLUMN_NAME =
'column';

--- End Message ---
--- Begin Message ---
yes, David, thanks
i know that

this query, for example:

select now(), item_count+10 as itemplus10, name
from mytable

i do not pretend that columns 1 and 2
bring to me the "column_comment" metadata because don't exist
but it would be helpful if i can get the column_comment metadata
of the column 3

i can have several joins,
it would be very useful to get implicitly
the original metadata of the columns that are included on the query
without modifications or calculations

since, in other way
i should have some schema for matching table and column names
with its metadata,
for example a php that setup an array of all columns
(from table columns)
indexed by "db.table.column"

the purpose of all this
is to get "labels" for each field
for use in the application


tell me please, what do you think?
i don't have much experience in php+mysql

thanks



David Otton escribió:
2009/11/24 keyser soze <bajopala...@yahoo.com.ar>:

mysqli_fetch_field provide result metadata
like 'column name', 'max length', 'datatype' etc
but i need the "comment" of each column

is this possible?

The table that stores data about columns is
information_schema.COLUMNS. You're looking for the COLUMN_COMMENT
column. Eg

SELECT COLUMN_COMMENT FROM information_schema.COLUMNS WHERE
TABLE_SCHEMA = 'database' AND TABLE_NAME = 'table' AND COLUMN_NAME =
'column';



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091123-1, 23/11/2009
Tested on: 24/11/2009 09:43:10 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--- End Message ---
--- Begin Message ---
Guys!

Here you both have a really good oportunity.
You have contacted each other and say a lot, try to make something of this!

Think on what you have done, design your idea, diagram a new set of classes,
propose an implementation, work together and write the best form generation
tool for all the community.

You know you can do it!

On Mon, Nov 23, 2009 at 11:54 PM, Manuel Lemos <mle...@acm.org> wrote:

> Hello Anonymous complainer,
>
> on 11/22/2009 09:23 AM LinuxManMikeC said the following:
> > Just like to share my real world experience with Manuel Lemos'
> > "formsgeneration" library.
> > http://www.phpclasses.org/formsgeneration
> >
> > At work early this summer we had a project under a tight deadline that
> > needed unified form creation, processing, and error reporting.  I had
> > seen Manuel promoting his formsgeneration class on the mailing list
> > and thought I'd look into it to help keep the project within the
> > deadline.  I read some positive reviews and comments, the demos looked
> > promising, and the interface seemed good enough.  Little did I know
> > the headaches I was in for.  I found the configuration structures and
> > interface to be extremely cumbersome, not to mention terribly
> > documented.  The interface seems quite inefficient and in most cases
> > its easier just to throw together a form and validation code by hand.
> > Usage was often convoluted, and due to the poor documentation I spent
> > half my effort trying to decipher the interface.  And it was difficult
> > to customize in several areas.  While it can work well enough in
> > several simple cases, in my opinion it is too cumbersome for any
> > significant form processing project, especially in the business world.
> >  I ended up wasting a week of work using the formsgeneration class and
> > had to redo the project making my own form utility code from scratch
> > as I went (which took just as much time and actually worked as
> > intended).  Granted I did make the mistake of not giving myself enough
> > evaluation time before the project.  I just want caution others to
> > carefully evaluate this code before deciding to use it in their
> > projects, especially since Manuel seems so eager to promote his code
> > (and his web site) whenever the opportunity arises.  And in general,
> > to be cautious and take your time when evaluating any 3rd party code
> > for production use.
>
> There seems to be a misunderstanding. I am not eager to promote my code.
> I just look forward to have my classes tested by as many people as
> possible, so I get as many bug reports and feature improvements as
> possible.
>
> The fact is that I developed this and many other packages for my own
> purposes. Nowadays I could not live without them because they make me
> several orders of magnitude more productive than if I had to do it edit
> HTML code mannually as you said you did.
>
> Anyway, maybe this surprises you, but I like criticism. Especially
> constructive criticisms from people that are able to give specific
> examples of what they do not like, instead of making vague claims as you
> did.
>
> I like constructive criticism because it helps me making my code better,
> more useful to others and ultimately to myself. That is why I publish my
> work as Open Source.
>
> Unfortunately you did make any constructive criticism. There seems to be
> no way to improve my work because you were not specific to what exactly
> you find cumbersome, even less what you would different to make it less
> cumbersome.
>
> I never claimed it would be perfect for everybody. What is good and
> productive for some, maybe hard and difficult for others, especially if
> you try to learn all by yourself and never ask for help.
>
> The class has a support forum where you can ask questions and always get
> a response so you never get stuck.
>
> http://www.phpclasses.org/discuss/package/1/
>
> Anyway, I don't know if you ever asked for help because you are using an
> anonymous identity here. Actually, I wonder why you bother to write a
> special message anonymously just campaign against the forms class. It
> makes me wonder if you have other reasons to do it that you may not be
> revealing unrelated with the class.
>
> Anyway, I am not upset. I am just sorry that you made many criticisms
> without giving real examples to demonstrate your points. That way it
> will not be helpful to anybody.
>
>
> --
>
> Regards,
> Manuel Lemos
>
> Find and post PHP jobs
> http://www.phpclasses.org/jobs/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta

--- End Message ---
--- Begin Message ---
Ave,

I'm connecting to a foxpro database (dbase) and simply running a search to retrieve a record. It's a very simple code. The problem is, as the database is growing, the search is becoming ridiculously slow ... and I mean it's taking "minutes". When the dbase had 10,000 records ... search was fast & efficient ... as if you were connecting to a mySQL Database. Now that the database has over 75,000 records and still growing ... it's taking minutes to search.

The database has about 35 fields; Search is based on a phone number.
This is the code ...

<?php
        #Open DBF
        $db = dbase_open("dbase.dbf", 0);
                
        #PULL UP RECORD
        if ($db) {
          $record_numbers = dbase_numrecords($db);
          for ($i = 1; $i <= $record_numbers; $i++) {
                 $row = dbase_get_record_with_names($db, $i);
                 if ($row['PHONE'] == $_POST['PHONE']) {
                        
                        #Retrieve row & display fields
                        echo $row['STUFF'];             
                }       
        }
}
?>

It works ... but it's getting way too slow.

One thing with FoxPro DBF's is that they use an Index file for searches within FoxPro. These are .CDX files which contain the Index. You can create an Index on, for example, PHONE field. However I don't think there's any way in PHP to reference this Index file for faster searches.

Is there any possibility to improve search response time?

Thanks!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





--- End Message ---
--- Begin Message ---
On Tue, 2009-11-24 at 08:40 -0500, Rahul S. Johari wrote:

> Ave,
> 
> I'm connecting to a foxpro database (dbase) and simply running a  
> search to retrieve a record. It's a very simple code.
> The problem is, as the database is growing, the search is becoming  
> ridiculously slow ... and I mean it's taking "minutes". When the dbase  
> had 10,000 records ... search was fast & efficient ... as if you were  
> connecting to a mySQL Database. Now that the database has over 75,000  
> records and still growing ... it's taking minutes to search.
> 
> The database has about 35 fields; Search is based on a phone number.
> This is the code ...
> 
> <?php
>       #Open DBF
>       $db = dbase_open("dbase.dbf", 0);
>               
>       #PULL UP RECORD
>       if ($db) {
>         $record_numbers = dbase_numrecords($db);
>         for ($i = 1; $i <= $record_numbers; $i++) {
>                $row = dbase_get_record_with_names($db, $i);
>                if ($row['PHONE'] == $_POST['PHONE']) {
>                       
>                       #Retrieve row & display fields
>                       echo $row['STUFF'];             
>               }       
>       }
> }
> ?>
> 
> It works ... but it's getting way too slow.
> 
> One thing with FoxPro DBF's is that they use an Index file for  
> searches within FoxPro. These are .CDX files which contain the Index.  
> You can create an Index on, for example, PHONE field. However I don't  
> think there's any way in PHP to reference this Index file for faster  
> searches.
> 
> Is there any possibility to improve search response time?
> 
> Thanks!
> 
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
> 
> [Email]       sleepwal...@rahulsjohari.com
> [Web] http://www.rahulsjohari.com
> 
> 
> 
> 
> 


I would assume that any indexes created on any tables would be
referenced automatically by the dbms and wouldn't need to be explicitly
referenced from within PHP.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---

On Nov 24, 2009, at 8:59 AM, Ashley Sheridan wrote:

On Tue, 2009-11-24 at 08:40 -0500, Rahul S. Johari wrote:

Ave,

I'm connecting to a foxpro database (dbase) and simply running a
search to retrieve a record. It's a very simple code.
The problem is, as the database is growing, the search is becoming
ridiculously slow ... and I mean it's taking "minutes". When the dbase
had 10,000 records ... search was fast & efficient ... as if you were
connecting to a mySQL Database. Now that the database has over 75,000
records and still growing ... it's taking minutes to search.

The database has about 35 fields; Search is based on a phone number.
This is the code ...

<?php
        #Open DBF
        $db = dbase_open("dbase.dbf", 0);
                
        #PULL UP RECORD
        if ($db) {
          $record_numbers = dbase_numrecords($db);
          for ($i = 1; $i <= $record_numbers; $i++) {
                 $row = dbase_get_record_with_names($db, $i);
                 if ($row['PHONE'] == $_POST['PHONE']) {
                        
                        #Retrieve row & display fields
                        echo $row['STUFF'];             
                }       
        }
}
?>

It works ... but it's getting way too slow.

One thing with FoxPro DBF's is that they use an Index file for
searches within FoxPro. These are .CDX files which contain the Index.
You can create an Index on, for example, PHONE field. However I don't
think there's any way in PHP to reference this Index file for faster
searches.

Is there any possibility to improve search response time?

Thanks!


I would assume that any indexes created on any tables would be
referenced automatically by the dbms and wouldn't need to be explicitly
referenced from within PHP.

Thanks,
Ash
http://www.ashleysheridan.co.uk



Makes sense; but I'm not sure if the Index is being referenced here ... based on the extremely slow searches.

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





--- End Message ---
--- Begin Message ---
even though the dbf has 10K records
Fox can't spend "minutes" to found a match
by the way, its very strange
to have 35 columns in a table/dbf or whatever....

pay attention to the comment of Ashley
in Fox, you should:

SELECT directory
INDEX on phone_number to idx_directory_phone
- or -
INDEX on phone_number tag phone of cdx_directory

i worked with Fox
with dbfs of 2 millions of records
and the speed is amazing -- using indexes of course!

regards,
ks





Rahul S. Johari escribió:
Ave,

I'm connecting to a foxpro database (dbase) and simply running a search to retrieve a record. It's a very simple code. The problem is, as the database is growing, the search is becoming ridiculously slow ... and I mean it's taking "minutes". When the dbase had 10,000 records ... search was fast & efficient ... as if you were connecting to a mySQL Database. Now that the database has over 75,000 records and still growing ... it's taking minutes to search.

The database has about 35 fields; Search is based on a phone number.
This is the code ...

<?php
    #Open DBF
    $db = dbase_open("dbase.dbf", 0);
#PULL UP RECORD
    if ($db) {
      $record_numbers = dbase_numrecords($db);
      for ($i = 1; $i <= $record_numbers; $i++) {
         $row = dbase_get_record_with_names($db, $i);
         if ($row['PHONE'] == $_POST['PHONE']) {
#Retrieve row & display fields echo $row['STUFF']; } }
}
?>

It works ... but it's getting way too slow.

One thing with FoxPro DBF's is that they use an Index file for searches within FoxPro. These are .CDX files which contain the Index. You can create an Index on, for example, PHONE field. However I don't think there's any way in PHP to reference this Index file for faster searches.

Is there any possibility to improve search response time?

Thanks!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email]    sleepwal...@rahulsjohari.com
[Web]    http://www.rahulsjohari.com







---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091124-0, 24/11/2009
Tested on: 24/11/2009 11:16:25 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--- End Message ---
--- Begin Message --- Your post definitely gives me hope. It's possible I'm doing something wrong! I definitely have the foxpro database indexed. I use this FoxPro command ...

INDEX ON PHONE TAG PHONE

I do have a .CDX file present for the Database and if I MODIFY STRUCTURE and I can see the INDEX present on PHONE.

Did you check my Code? Is there any other way to pull records off a FoxPro Database? Can you use SQL Commands via PHP on FoxPro databases (SELECT * FROM .... ) ?

Thanks



On Nov 24, 2009, at 9:16 AM, keyser soze wrote:

even though the dbf has 10K records
Fox can't spend "minutes" to found a match
by the way, its very strange
to have 35 columns in a table/dbf or whatever....

pay attention to the comment of Ashley
in Fox, you should:

SELECT directory
INDEX on phone_number to idx_directory_phone
- or -
INDEX on phone_number tag phone of cdx_directory

i worked with Fox
with dbfs of 2 millions of records
and the speed is amazing -- using indexes of course!

regards,
ks





Rahul S. Johari escribió:
Ave,
I'm connecting to a foxpro database (dbase) and simply running a search to retrieve a record. It's a very simple code. The problem is, as the database is growing, the search is becoming ridiculously slow ... and I mean it's taking "minutes". When the dbase had 10,000 records ... search was fast & efficient ... as if you were connecting to a mySQL Database. Now that the database has over 75,000 records and still growing ... it's taking minutes to search.
The database has about 35 fields; Search is based on a phone number.
This is the code ...
<?php
   #Open DBF
   $db = dbase_open("dbase.dbf", 0);
          #PULL UP RECORD
   if ($db) {
     $record_numbers = dbase_numrecords($db);
     for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($db, $i);
        if ($row['PHONE'] == $_POST['PHONE']) {
                      #Retrieve row & display fields
           echo $row['STUFF'];               }       }
}
?>
It works ... but it's getting way too slow.
One thing with FoxPro DBF's is that they use an Index file for searches within FoxPro. These are .CDX files which contain the Index. You can create an Index on, for example, PHONE field. However I don't think there's any way in PHP to reference this Index file for faster searches.
Is there any possibility to improve search response time?
Thanks!
---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.
[Email]    sleepwal...@rahulsjohari.com
[Web]    http://www.rahulsjohari.com


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091124-0, 24/11/2009
Tested on: 24/11/2009 11:16:25 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





--- End Message ---
--- Begin Message ---
i will try to help you
but think i'm old in Fox but new in php
and sadly never used php+fox

so, reading your code
i see you are scanning the whole dbf file from php
Fox cant help you in this way

if there is not another option for scan a dbf
the row by row method is very slow




Rahul S. Johari escribió:
Your post definitely gives me hope. It's possible I'm doing something wrong! I definitely have the foxpro database indexed. I use this FoxPro command ...

INDEX ON PHONE TAG PHONE

I do have a .CDX file present for the Database and if I MODIFY STRUCTURE and I can see the INDEX present on PHONE.

Did you check my Code? Is there any other way to pull records off a FoxPro Database? Can you use SQL Commands via PHP on FoxPro databases (SELECT * FROM .... ) ?

Thanks



On Nov 24, 2009, at 9:16 AM, keyser soze wrote:

even though the dbf has 10K records
Fox can't spend "minutes" to found a match
by the way, its very strange
to have 35 columns in a table/dbf or whatever....

pay attention to the comment of Ashley
in Fox, you should:

SELECT directory
INDEX on phone_number to idx_directory_phone
- or -
INDEX on phone_number tag phone of cdx_directory

i worked with Fox
with dbfs of 2 millions of records
and the speed is amazing -- using indexes of course!

regards,
ks





Rahul S. Johari escribió:
Ave,
I'm connecting to a foxpro database (dbase) and simply running a search to retrieve a record. It's a very simple code. The problem is, as the database is growing, the search is becoming ridiculously slow ... and I mean it's taking "minutes". When the dbase had 10,000 records ... search was fast & efficient ... as if you were connecting to a mySQL Database. Now that the database has over 75,000 records and still growing ... it's taking minutes to search.
The database has about 35 fields; Search is based on a phone number.
This is the code ...
<?php
   #Open DBF
   $db = dbase_open("dbase.dbf", 0);
          #PULL UP RECORD
   if ($db) {
     $record_numbers = dbase_numrecords($db);
     for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($db, $i);
        if ($row['PHONE'] == $_POST['PHONE']) {
                      #Retrieve row & display fields
           echo $row['STUFF'];               }       }
}
?>
It works ... but it's getting way too slow.
One thing with FoxPro DBF's is that they use an Index file for searches within FoxPro. These are .CDX files which contain the Index. You can create an Index on, for example, PHONE field. However I don't think there's any way in PHP to reference this Index file for faster searches.
Is there any possibility to improve search response time?
Thanks!
---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.
[Email]    sleepwal...@rahulsjohari.com
[Web]    http://www.rahulsjohari.com


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091124-0, 24/11/2009
Tested on: 24/11/2009 11:16:25 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email]    sleepwal...@rahulsjohari.com
[Web]    http://www.rahulsjohari.com







---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 091124-0, 24/11/2009
Tested on: 24/11/2009 11:55:50 a.m.
avast! - copyright (c) 1988-2009 ALWIL Software.
http://www.avast.com





--- End Message ---
--- Begin Message ---
El día 23 de noviembre de 2009 13:25, Nathan Rixham
<nrix...@gmail.com> escribió:
> Juan Marcelo Rodríguez Monti wrote:
>> Hi people,
>> I have some doubts about this topic that I'm gonna explain.
>>
>> I have a few sites in flash, and I was requested to write a PHP frontend
>> to send news. I have this already done and it works perfect. It's a LAMP
>> App to send and edit news, post video, images and so on.
>>
>> Then, I need to put all this news into the Flash site. So, I need to use
>> XML. I'm not gonna discuss about Flash, because this is a PHP List,
>> however I would like to talk about PHP and XML.
>>
>> What do you recommend me to produce XML from those news of the SQL
>> database?. What do you suggest to output XML from the existing content
>> to then put those XML files into Flash.
>>
>> The posted news are saved in a MySQL database. I don't know if do I need
>> to output from PHP then parse the output and convert it to XML, or if Do
>> I need to get the array from the MySQL and directly output this to an
>> XML file to then get from this file from Flash.
>>
>> Thanks,
>> Juan.
>>
>
> flash remoting: you could use amf instead; its faster and easier to use.
>
> on the php side just use http://amfphp.org/ or suchlike

Thanks. I didn't know that. Did you test this applications ?  How well
does it work ?.

Juan

--- End Message ---
--- Begin Message --- I'm having an include problem on a shared host and need the answer to the following to cover a key point.

I'm getting this error:
Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion include_path='.:/usr/lib/php:/usr/local/lib/php:/home1/youstart/php/') in /home1/youstart/php/Mail/smtp.php on line 206

What's going on is that my script calls /php/mail.php which includes /Mail/smtp.php. smtp.php has "include Net/SMTP.php" on line 206.

This bothers since the current working directory is effectively where my original script resides; is it not? If so, doesn't the "include Net/SMTP.php on line 206" look for the path relative to it and not in /home1/youstart/php/?

If my assumption is correct, is there a way around the problem? Remember, this is a shared host and changing stuff above the /public_html is a real problem.

My script runs fine on 3 other Linux/Appache/cpanel shared-host servers.

Al.......

--- End Message ---

Reply via email to