Hi Alvaro,

I have no experience using these in PHP scripts.  Couldn't hurt to try
putting it in mysql_query statements and see if it works.  If you can
turn on the general query log for a bit then you can see exactly if
it's working; if you can't turn it on, then you'll have to guess from
output.

-Sheeri

On 2/22/06, Alvaro Cobo <[EMAIL PROTECTED]> wrote:
> Thanks Sheeri:
>
> Yes, you where right. It was because I was not opening the table first.
> Actually, I was using this statements from a MySQL GUI (MySQL Query
> Browser) so it doesn't work in this program (it doesn't keeps the table
> opened).
>
> But when I use your example in the shell mode it works perfect.
>
> Have you ever tried to use this kind of statements using PHP?. It is
> because I would like to use it in a PHP script (I was exploring this
> function to make a navigator which sends me to the next record each time
> I click on a link generated from a MySQL query).
>
> Thanks a lot and very grateful with you,
>
> Alvaro.
>
> sheeri kritzer escribió:
> > Hi there,
> >
> > What did your MySQL error say?
> >
> > It looks like you didn't open the table.  my example, which worked:
> >
> > CREATE TABLE `foo` (
> >   `id` int(11) NOT NULL auto_increment,
> >   `bar` char(3) default NULL,
> >   PRIMARY KEY  (`id`),
> >   KEY `idx_bar` (`bar`)
> > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
> >
> > insert into foo (bar) VALUES
> > ('abc'),('def'),('qwe'),('ert'),('wer'),('tyu'),('asd'),('sdf'),('dfg'),('zxc'),('xcc');
> >
> > and then:
> >
> > mysql> HANDLER foo open;
> > Query OK, 0 rows affected (0.00 sec)
> >
> > mysql> HANDLER foo READ idx_bar FIRST where bar='wer';
> > +----+------+
> > | id | bar  |
> > +----+------+
> > |  5 | wer  |
> > +----+------+
> > 1 row in set (0.00 sec)
> >
> > mysql> HANDLER foo READ idx_bar NEXT;
> > +----+------+
> > | id | bar  |
> > +----+------+
> > | 11 | xcc  |
> > +----+------+
> > 1 row in set (0.00 sec)
> >
> > mysql> HANDLER foo READ idx_bar PREV;
> > +----+------+
> > | id | bar  |
> > +----+------+
> > |  5 | wer  |
> > +----+------+
> > 1 row in set (0.00 sec)
> >
> > mysql> HANDLER foo READ idx_bar PREV;
> > +----+------+
> > | id | bar  |
> > +----+------+
> > |  6 | tyu  |
> > +----+------+
> > 1 row in set (0.00 sec)
> >
> > Granted, that's using "previous" and "next" in an alphabetical sense.
> > I found that using the "id" index didn't work, and I had to create
> > another non-primary index on key for it to work.
> >
> > -Sheeri
> >
> >
> > On 2/8/06, Alvaro Cobo <[EMAIL PROTECTED]> wrote:
> >> Dear all:
> >>
> >> I have been exploring about this issue quite a lot, and find no solution:
> >>
> >> Platform: Debian, MySql 4.1.11, PHP 4.3.10-2, Apache.
> >>
> >> Is there any way I can retrieve a set of values depending in a where 
> >> clause:
> >>
> >> For example:
> >>
> >> from a set of values in one field: 1,2,5,8,9,11,13
> >>
> >> I'd like to retrieve a record (8) and also the previous one (5) and the
> >> next one (9) (so the record set would be: 5,8,9)
> >>
> >> I have found the "Handler" function in the Manual, but it and keeps
> >> giving me errors (I have also checked in the manual and it seems to work
> >> with MySql 4.1.x)
> >>
> >> /* --Start example
> >> ---------------------
> >> HANDLER tbl_sm04_indicador READ PK_indicador_id { FIRST | NEXT | PREV |
> >> LAST }
> >>
> >> WHERE PK_indicador_id=8
> >>
> >> LIMIT 0, 3
> >> ----------------------
> >> --End example (I know, I am completely lost)*/
> >>
> >> Does anybody has tried this function before?.
> >> Is it useful for the result I would like to accomplish?
> >> Could anybody could share an example of how to use this function?
> >>
> >> Thanks and best regards.
> >>
> >> Alvaro Cobo
> >>
> >> --
> >> MySQL General Mailing List
> >> For list archives: http://lists.mysql.com/mysql
> >> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> >>
> >>
> >
> >
>
>
>
>
>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to