php-general Digest 16 Aug 2009 10:52:53 -0000 Issue 6288

Topics (messages 296822 through 296835):

Re: File or directory?
        296822 by: Clancy

Issue with the huge import script
        296823 by: Devendra Jadhav
        296824 by: Ralph Deffke
        296828 by: Ashley Sheridan
        296830 by: Ralph Deffke
        296831 by: Ashley Sheridan
        296832 by: Ralph Deffke
        296833 by: Ashley Sheridan
        296834 by: Ollisso
        296835 by: Ralph Deffke

How do I extract link text from anchor tag as well as the URL from the "href" 
attribute
        296825 by: chrysanhy
        296827 by: Ralph Deffke

Re: Another date exercise
        296826 by: Lester Caine
        296829 by: Ashley Sheridan

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 Sat, 15 Aug 2009 10:33:07 +0100, a...@ashleysheridan.co.uk (Ashley Sheridan) 
wrote:

>On Sat, 2009-08-15 at 09:56 +0200, Ralph Deffke wrote:
>> can u upload ur own files ?
>> can u create a directory ?

Yes.

>> are u using a ftp client ?

No; I'm using straight PHP FTP
>> 
>> 
>> "Clancy" <clanc...@cybec.com.au> wrote in message
>> news:kjhc85hpub7drihgappifphcboolt9u...@4ax.com...
>> > I have just got access to a new server, and am playing with
>> upload/download procedures. I
>> > looked in the root directory, and see several objects which I assume to be
>> directories.
>> > However I was surprised to find there does not appear to be any command to
>> determine if an
>> > object is a file or directory, either in PHP FTP or plain FTP.  I could
>> try to change to
>> > them, or download them, but this seems overkill.  Am I overlooking
>> something obvious?
>> 
>> 
>> 
>That answer doesn't seem to quite come close even to answering the op
>question.
>
>Have you looked at ftp_rawlist which returns a detailed list of files,
>along with their permissions and directory flags? Or you could use
>ftp_size to determine the size of a file, which should be nothing for a
>directory.

Thanks,

Yes; I found ftp_rawlist eventually, but I still haven't found a definition of 
the return
code, though I think I know most of it.

I guess that even a null file will hve some length?  I will probably use the 
leading 'd'
in the return code to test for directories..

(And I spent a long time trying to work out how 'drwxr-xr-x 2 riordan riordan 
512 Jul 31
06:40 cgi-bin' could contain lots of spaces, before I remembered that, as a 
result of one
of the weirder design decisions,  HTML suppresses trailing spaces.)


--- End Message ---
--- Begin Message ---
Hi,

I have to import data from one database to another, I have to import around
100000(1Lac) records.
First I need to check if the record is already imported or not and import
only those records which are not imported.

Here is my logic

$already_imported = get_already_imported_records();
format of the $already_imported is $already_imported[someid] = 'imported';

Now i take all records from another db and iterating through it.

if (!key_exists($already_imported[$new_id])){
        import_function($new_id)
}else{
        echo 'allready imported'.$already_imported[$new_id];
}

Now my script is importing same records for more than one time. I am not
able to get through this issue

Is it because of the size of the records or something else...?

Please suggest me some solution which is faster, safe and easy to code :D

Thanks in advance

-- 
Devendra Jadhav

--- End Message ---
--- Begin Message ---
Hi,

this sounds huge, and cries for a sql version of the import.
Are both databases the same? MySQL?

I give u a draft for MySQL
u export the data u have, then u got a textfile with 100000+ sql statments

in the php script u open the file and iterate over it by line (carefull it
could be also ";" in case its a Unix created file on a windows platform)

line == one SQL insert in table bla bla...

in the loop then just mysq_query with this line

if the the someid is an unique index the insert will fail, so only those
records are inserted beeing not already in the database.

but I think as of the amount off records it doesn't sound like a every 10
minutes job, if it is a rara job, just do it with phpMyAdmin

sorry not pulling out the code, but was a long day behind the keyboard, need
some sleep

ralph_def...@yahoo.de




"Devendra Jadhav" <devendra...@gmail.com> wrote in message
news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> Hi,
>
> I have to import data from one database to another, I have to import
around
> 100000(1Lac) records.
> First I need to check if the record is already imported or not and import
> only those records which are not imported.
>
> Here is my logic
>
> $already_imported = get_already_imported_records();
> format of the $already_imported is $already_imported[someid] = 'imported';
>
> Now i take all records from another db and iterating through it.
>
> if (!key_exists($already_imported[$new_id])){
>         import_function($new_id)
> }else{
>         echo 'allready imported'.$already_imported[$new_id];
> }
>
> Now my script is importing same records for more than one time. I am not
> able to get through this issue
>
> Is it because of the size of the records or something else...?
>
> Please suggest me some solution which is faster, safe and easy to code :D
>
> Thanks in advance
>
> -- 
> Devendra Jadhav
>



--- End Message ---
--- Begin Message ---
On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> Hi,
> 
> this sounds huge, and cries for a sql version of the import.
> Are both databases the same? MySQL?
> 
> I give u a draft for MySQL
> u export the data u have, then u got a textfile with 100000+ sql statments
> 
> in the php script u open the file and iterate over it by line (carefull it
> could be also ";" in case its a Unix created file on a windows platform)
> 
> line == one SQL insert in table bla bla...
> 
> in the loop then just mysq_query with this line
> 
> if the the someid is an unique index the insert will fail, so only those
> records are inserted beeing not already in the database.
> 
> but I think as of the amount off records it doesn't sound like a every 10
> minutes job, if it is a rara job, just do it with phpMyAdmin
> 
> sorry not pulling out the code, but was a long day behind the keyboard, need
> some sleep
> 
> ralph_def...@yahoo.de
> 
> 
> 
> 
> "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > Hi,
> >
> > I have to import data from one database to another, I have to import
> around
> > 100000(1Lac) records.
> > First I need to check if the record is already imported or not and import
> > only those records which are not imported.
> >
> > Here is my logic
> >
> > $already_imported = get_already_imported_records();
> > format of the $already_imported is $already_imported[someid] = 'imported';
> >
> > Now i take all records from another db and iterating through it.
> >
> > if (!key_exists($already_imported[$new_id])){
> >         import_function($new_id)
> > }else{
> >         echo 'allready imported'.$already_imported[$new_id];
> > }
> >
> > Now my script is importing same records for more than one time. I am not
> > able to get through this issue
> >
> > Is it because of the size of the records or something else...?
> >
> > Please suggest me some solution which is faster, safe and easy to code :D
> >
> > Thanks in advance
> >
> > -- 
> > Devendra Jadhav
> >
> 
> 
> 
You cry for a MySQL version and then revert back to PHP?! Why not just
keep the whole thing in MySQL? You can use SQL statements to check
whether a record exists before attempting to shove it in the database
using a WHERE clause in the INSERT statement or by making one field
unique and hiding notices about inserts that are attempting to overwrite
that.

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


--- End Message ---
--- Begin Message ---
because I assume always that a requester got some intelligence, so in that
case there must be a reasonsble reason why he wants to do it in PHP

im not like u assuming everybody is a thumb

ralph

"Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
news:1250413427.2344.51.ca...@localhost...
> On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> > Hi,
> >
> > this sounds huge, and cries for a sql version of the import.
> > Are both databases the same? MySQL?
> >
> > I give u a draft for MySQL
> > u export the data u have, then u got a textfile with 100000+ sql
statments
> >
> > in the php script u open the file and iterate over it by line (carefull
it
> > could be also ";" in case its a Unix created file on a windows platform)
> >
> > line == one SQL insert in table bla bla...
> >
> > in the loop then just mysq_query with this line
> >
> > if the the someid is an unique index the insert will fail, so only those
> > records are inserted beeing not already in the database.
> >
> > but I think as of the amount off records it doesn't sound like a every
10
> > minutes job, if it is a rara job, just do it with phpMyAdmin
> >
> > sorry not pulling out the code, but was a long day behind the keyboard,
need
> > some sleep
> >
> > ralph_def...@yahoo.de
> >
> >
> >
> >
> > "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> > news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > > Hi,
> > >
> > > I have to import data from one database to another, I have to import
> > around
> > > 100000(1Lac) records.
> > > First I need to check if the record is already imported or not and
import
> > > only those records which are not imported.
> > >
> > > Here is my logic
> > >
> > > $already_imported = get_already_imported_records();
> > > format of the $already_imported is $already_imported[someid] =
'imported';
> > >
> > > Now i take all records from another db and iterating through it.
> > >
> > > if (!key_exists($already_imported[$new_id])){
> > >         import_function($new_id)
> > > }else{
> > >         echo 'allready imported'.$already_imported[$new_id];
> > > }
> > >
> > > Now my script is importing same records for more than one time. I am
not
> > > able to get through this issue
> > >
> > > Is it because of the size of the records or something else...?
> > >
> > > Please suggest me some solution which is faster, safe and easy to code
:D
> > >
> > > Thanks in advance
> > >
> > > -- 
> > > Devendra Jadhav
> > >
> >
> >
> >
> You cry for a MySQL version and then revert back to PHP?! Why not just
> keep the whole thing in MySQL? You can use SQL statements to check
> whether a record exists before attempting to shove it in the database
> using a WHERE clause in the INSERT statement or by making one field
> unique and hiding notices about inserts that are attempting to overwrite
> that.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>



--- End Message ---
--- Begin Message ---
On Sun, 2009-08-16 at 11:05 +0200, Ralph Deffke wrote:
> because I assume always that a requester got some intelligence, so in that
> case there must be a reasonsble reason why he wants to do it in PHP
> 
> im not like u assuming everybody is a thumb
> 
> ralph
> 
> "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> news:1250413427.2344.51.ca...@localhost...
> > On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> > > Hi,
> > >
> > > this sounds huge, and cries for a sql version of the import.
> > > Are both databases the same? MySQL?
> > >
> > > I give u a draft for MySQL
> > > u export the data u have, then u got a textfile with 100000+ sql
> statments
> > >
> > > in the php script u open the file and iterate over it by line (carefull
> it
> > > could be also ";" in case its a Unix created file on a windows platform)
> > >
> > > line == one SQL insert in table bla bla...
> > >
> > > in the loop then just mysq_query with this line
> > >
> > > if the the someid is an unique index the insert will fail, so only those
> > > records are inserted beeing not already in the database.
> > >
> > > but I think as of the amount off records it doesn't sound like a every
> 10
> > > minutes job, if it is a rara job, just do it with phpMyAdmin
> > >
> > > sorry not pulling out the code, but was a long day behind the keyboard,
> need
> > > some sleep
> > >
> > > ralph_def...@yahoo.de
> > >
> > >
> > >
> > >
> > > "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> > > news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > > > Hi,
> > > >
> > > > I have to import data from one database to another, I have to import
> > > around
> > > > 100000(1Lac) records.
> > > > First I need to check if the record is already imported or not and
> import
> > > > only those records which are not imported.
> > > >
> > > > Here is my logic
> > > >
> > > > $already_imported = get_already_imported_records();
> > > > format of the $already_imported is $already_imported[someid] =
> 'imported';
> > > >
> > > > Now i take all records from another db and iterating through it.
> > > >
> > > > if (!key_exists($already_imported[$new_id])){
> > > >         import_function($new_id)
> > > > }else{
> > > >         echo 'allready imported'.$already_imported[$new_id];
> > > > }
> > > >
> > > > Now my script is importing same records for more than one time. I am
> not
> > > > able to get through this issue
> > > >
> > > > Is it because of the size of the records or something else...?
> > > >
> > > > Please suggest me some solution which is faster, safe and easy to code
> :D
> > > >
> > > > Thanks in advance
> > > >
> > > > -- 
> > > > Devendra Jadhav
> > > >
> > >
> > >
> > >
> > You cry for a MySQL version and then revert back to PHP?! Why not just
> > keep the whole thing in MySQL? You can use SQL statements to check
> > whether a record exists before attempting to shove it in the database
> > using a WHERE clause in the INSERT statement or by making one field
> > unique and hiding notices about inserts that are attempting to overwrite
> > that.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> 
> 
There are rare occasions on this list where the best answer is not PHP,
and I believe this is one of them.

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


--- End Message ---
--- Begin Message ---
so then tell me tell me what my first sentence means

"this sounds huge, and cries for a sql version of the import."

it looks like u have no experience in working as consultant  hotlines Ash
first the folk is asking for a sulotion of HIS php implying a general
solution in PHP with a hint to the prof solution

I think thats what I did


"Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
news:1250414284.2344.55.ca...@localhost...
> On Sun, 2009-08-16 at 11:05 +0200, Ralph Deffke wrote:
> > because I assume always that a requester got some intelligence, so in
that
> > case there must be a reasonsble reason why he wants to do it in PHP
> >
> > im not like u assuming everybody is a thumb
> >
> > ralph
> >
> > "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> > news:1250413427.2344.51.ca...@localhost...
> > > On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> > > > Hi,
> > > >
> > > > this sounds huge, and cries for a sql version of the import.
> > > > Are both databases the same? MySQL?
> > > >
> > > > I give u a draft for MySQL
> > > > u export the data u have, then u got a textfile with 100000+ sql
> > statments
> > > >
> > > > in the php script u open the file and iterate over it by line
(carefull
> > it
> > > > could be also ";" in case its a Unix created file on a windows
platform)
> > > >
> > > > line == one SQL insert in table bla bla...
> > > >
> > > > in the loop then just mysq_query with this line
> > > >
> > > > if the the someid is an unique index the insert will fail, so only
those
> > > > records are inserted beeing not already in the database.
> > > >
> > > > but I think as of the amount off records it doesn't sound like a
every
> > 10
> > > > minutes job, if it is a rara job, just do it with phpMyAdmin
> > > >
> > > > sorry not pulling out the code, but was a long day behind the
keyboard,
> > need
> > > > some sleep
> > > >
> > > > ralph_def...@yahoo.de
> > > >
> > > >
> > > >
> > > >
> > > > "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> > > > news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > > > > Hi,
> > > > >
> > > > > I have to import data from one database to another, I have to
import
> > > > around
> > > > > 100000(1Lac) records.
> > > > > First I need to check if the record is already imported or not and
> > import
> > > > > only those records which are not imported.
> > > > >
> > > > > Here is my logic
> > > > >
> > > > > $already_imported = get_already_imported_records();
> > > > > format of the $already_imported is $already_imported[someid] =
> > 'imported';
> > > > >
> > > > > Now i take all records from another db and iterating through it.
> > > > >
> > > > > if (!key_exists($already_imported[$new_id])){
> > > > >         import_function($new_id)
> > > > > }else{
> > > > >         echo 'allready imported'.$already_imported[$new_id];
> > > > > }
> > > > >
> > > > > Now my script is importing same records for more than one time. I
am
> > not
> > > > > able to get through this issue
> > > > >
> > > > > Is it because of the size of the records or something else...?
> > > > >
> > > > > Please suggest me some solution which is faster, safe and easy to
code
> > :D
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > > -- 
> > > > > Devendra Jadhav
> > > > >
> > > >
> > > >
> > > >
> > > You cry for a MySQL version and then revert back to PHP?! Why not just
> > > keep the whole thing in MySQL? You can use SQL statements to check
> > > whether a record exists before attempting to shove it in the database
> > > using a WHERE clause in the INSERT statement or by making one field
> > > unique and hiding notices about inserts that are attempting to
overwrite
> > > that.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> >
> >
> >
> There are rare occasions on this list where the best answer is not PHP,
> and I believe this is one of them.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>



--- End Message ---
--- Begin Message ---
On Sun, 2009-08-16 at 11:25 +0200, Ralph Deffke wrote:
> so then tell me tell me what my first sentence means
> 
> "this sounds huge, and cries for a sql version of the import."
> 
> it looks like u have no experience in working as consultant  hotlines Ash
> first the folk is asking for a sulotion of HIS php implying a general
> solution in PHP with a hint to the prof solution
> 
> I think thats what I did
> 
> 
> "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> news:1250414284.2344.55.ca...@localhost...
> > On Sun, 2009-08-16 at 11:05 +0200, Ralph Deffke wrote:
> > > because I assume always that a requester got some intelligence, so in
> that
> > > case there must be a reasonsble reason why he wants to do it in PHP
> > >
> > > im not like u assuming everybody is a thumb
> > >
> > > ralph
> > >
> > > "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> > > news:1250413427.2344.51.ca...@localhost...
> > > > On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> > > > > Hi,
> > > > >
> > > > > this sounds huge, and cries for a sql version of the import.
> > > > > Are both databases the same? MySQL?
> > > > >
> > > > > I give u a draft for MySQL
> > > > > u export the data u have, then u got a textfile with 100000+ sql
> > > statments
> > > > >
> > > > > in the php script u open the file and iterate over it by line
> (carefull
> > > it
> > > > > could be also ";" in case its a Unix created file on a windows
> platform)
> > > > >
> > > > > line == one SQL insert in table bla bla...
> > > > >
> > > > > in the loop then just mysq_query with this line
> > > > >
> > > > > if the the someid is an unique index the insert will fail, so only
> those
> > > > > records are inserted beeing not already in the database.
> > > > >
> > > > > but I think as of the amount off records it doesn't sound like a
> every
> > > 10
> > > > > minutes job, if it is a rara job, just do it with phpMyAdmin
> > > > >
> > > > > sorry not pulling out the code, but was a long day behind the
> keyboard,
> > > need
> > > > > some sleep
> > > > >
> > > > > ralph_def...@yahoo.de
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> > > > > news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > > > > > Hi,
> > > > > >
> > > > > > I have to import data from one database to another, I have to
> import
> > > > > around
> > > > > > 100000(1Lac) records.
> > > > > > First I need to check if the record is already imported or not and
> > > import
> > > > > > only those records which are not imported.
> > > > > >
> > > > > > Here is my logic
> > > > > >
> > > > > > $already_imported = get_already_imported_records();
> > > > > > format of the $already_imported is $already_imported[someid] =
> > > 'imported';
> > > > > >
> > > > > > Now i take all records from another db and iterating through it.
> > > > > >
> > > > > > if (!key_exists($already_imported[$new_id])){
> > > > > >         import_function($new_id)
> > > > > > }else{
> > > > > >         echo 'allready imported'.$already_imported[$new_id];
> > > > > > }
> > > > > >
> > > > > > Now my script is importing same records for more than one time. I
> am
> > > not
> > > > > > able to get through this issue
> > > > > >
> > > > > > Is it because of the size of the records or something else...?
> > > > > >
> > > > > > Please suggest me some solution which is faster, safe and easy to
> code
> > > :D
> > > > > >
> > > > > > Thanks in advance
> > > > > >
> > > > > > -- 
> > > > > > Devendra Jadhav
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > You cry for a MySQL version and then revert back to PHP?! Why not just
> > > > keep the whole thing in MySQL? You can use SQL statements to check
> > > > whether a record exists before attempting to shove it in the database
> > > > using a WHERE clause in the INSERT statement or by making one field
> > > > unique and hiding notices about inserts that are attempting to
> overwrite
> > > > that.
> > > >
> > > > Thanks,
> > > > Ash
> > > > http://www.ashleysheridan.co.uk
> > > >
> > >
> > >
> > >
> > There are rare occasions on this list where the best answer is not PHP,
> > and I believe this is one of them.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> 
> 
You did say this cries for a pure SQL solution, which you then went on
to say involved PHP. Call me a pedant, but PHP is not SQL. And please,
try to leave insults out of the list in future, it makes you look
unprofessional.

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


--- End Message ---
--- Begin Message --- On Sun, 16 Aug 2009 04:15:12 +0300, Devendra Jadhav <devendra...@gmail.com> wrote:

Is it because of the size of the records or something else...?

Please suggest me some solution which is faster, safe and easy to code :D


What about using insert ignore ? :)

1. add UNIQUE constraint on a key you want to add, so you won't be able to add row with same ID twice.
2. then use INSERT IGNORE into ....

=> easy to code, easy to use.

Of course, this aproach won't work if database will grow larger and larger. (if you adding new rows all the time)

Then it is better to use this aproach:

1. add auto_increment column to original table.
2. before getting new rows from old table, check what is maximum ID from new table. 3. get only rows where old_table.id > new_table.max_id remember to ORDER BY ID ASC.



--

--- End Message ---
--- Begin Message ---
better consider if u r insulting I've seen a view posts of u falling into
that category i w'ld recomment respect posters first approaches even if they
r stupid and incorporate the respect in the way u answer

the comment "you r crying ..." is an insult.

"Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
news:1250417781.2344.58.ca...@localhost...
> On Sun, 2009-08-16 at 11:25 +0200, Ralph Deffke wrote:
> > so then tell me tell me what my first sentence means
> >
> > "this sounds huge, and cries for a sql version of the import."
> >
> > it looks like u have no experience in working as consultant  hotlines
Ash
> > first the folk is asking for a sulotion of HIS php implying a general
> > solution in PHP with a hint to the prof solution
> >
> > I think thats what I did
> >
> >
> > "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> > news:1250414284.2344.55.ca...@localhost...
> > > On Sun, 2009-08-16 at 11:05 +0200, Ralph Deffke wrote:
> > > > because I assume always that a requester got some intelligence, so
in
> > that
> > > > case there must be a reasonsble reason why he wants to do it in PHP
> > > >
> > > > im not like u assuming everybody is a thumb
> > > >
> > > > ralph
> > > >
> > > > "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote in message
> > > > news:1250413427.2344.51.ca...@localhost...
> > > > > On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote:
> > > > > > Hi,
> > > > > >
> > > > > > this sounds huge, and cries for a sql version of the import.
> > > > > > Are both databases the same? MySQL?
> > > > > >
> > > > > > I give u a draft for MySQL
> > > > > > u export the data u have, then u got a textfile with 100000+ sql
> > > > statments
> > > > > >
> > > > > > in the php script u open the file and iterate over it by line
> > (carefull
> > > > it
> > > > > > could be also ";" in case its a Unix created file on a windows
> > platform)
> > > > > >
> > > > > > line == one SQL insert in table bla bla...
> > > > > >
> > > > > > in the loop then just mysq_query with this line
> > > > > >
> > > > > > if the the someid is an unique index the insert will fail, so
only
> > those
> > > > > > records are inserted beeing not already in the database.
> > > > > >
> > > > > > but I think as of the amount off records it doesn't sound like a
> > every
> > > > 10
> > > > > > minutes job, if it is a rara job, just do it with phpMyAdmin
> > > > > >
> > > > > > sorry not pulling out the code, but was a long day behind the
> > keyboard,
> > > > need
> > > > > > some sleep
> > > > > >
> > > > > > ralph_def...@yahoo.de
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Devendra Jadhav" <devendra...@gmail.com> wrote in message
> > > > > >
news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have to import data from one database to another, I have to
> > import
> > > > > > around
> > > > > > > 100000(1Lac) records.
> > > > > > > First I need to check if the record is already imported or not
and
> > > > import
> > > > > > > only those records which are not imported.
> > > > > > >
> > > > > > > Here is my logic
> > > > > > >
> > > > > > > $already_imported = get_already_imported_records();
> > > > > > > format of the $already_imported is $already_imported[someid] =
> > > > 'imported';
> > > > > > >
> > > > > > > Now i take all records from another db and iterating through
it.
> > > > > > >
> > > > > > > if (!key_exists($already_imported[$new_id])){
> > > > > > >         import_function($new_id)
> > > > > > > }else{
> > > > > > >         echo 'allready imported'.$already_imported[$new_id];
> > > > > > > }
> > > > > > >
> > > > > > > Now my script is importing same records for more than one
time. I
> > am
> > > > not
> > > > > > > able to get through this issue
> > > > > > >
> > > > > > > Is it because of the size of the records or something else...?
> > > > > > >
> > > > > > > Please suggest me some solution which is faster, safe and easy
to
> > code
> > > > :D
> > > > > > >
> > > > > > > Thanks in advance
> > > > > > >
> > > > > > > -- 
> > > > > > > Devendra Jadhav
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > You cry for a MySQL version and then revert back to PHP?! Why not
just
> > > > > keep the whole thing in MySQL? You can use SQL statements to check
> > > > > whether a record exists before attempting to shove it in the
database
> > > > > using a WHERE clause in the INSERT statement or by making one
field
> > > > > unique and hiding notices about inserts that are attempting to
> > overwrite
> > > > > that.
> > > > >
> > > > > Thanks,
> > > > > Ash
> > > > > http://www.ashleysheridan.co.uk
> > > > >
> > > >
> > > >
> > > >
> > > There are rare occasions on this list where the best answer is not
PHP,
> > > and I believe this is one of them.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> >
> >
> >
> You did say this cries for a pure SQL solution, which you then went on
> to say involved PHP. Call me a pedant, but PHP is not SQL. And please,
> try to leave insults out of the list in future, it makes you look
> unprofessional.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>



--- End Message ---
--- Begin Message ---
I have the following code to extract the URLs from the anchor tags of an
HTML page:

$html = new DOMDocument();
$htmlpage->loadHtmlFile($location);
$xpath = new DOMXPath($htmlpage);
$links = $xpath->query( '//a' );
foreach ($links as $link)
{ $int_url_list[$i++] = $link->getAttribute( 'href' ) . "\n"; }

If I have a link <a href="http://X.com";>YYYY</a>, how do I extract the
corresponding YYYY which is displayed to the user as the text of the link
(if it's an image tag, I would like a DOMElement for that).
Thanks

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

$link->nodeValue()

or

$link->getContent()

im not shure which one works on an image link which is indeed a child of <a
so u could also check if the node has a child, if so its an image with, in
good practice. an alt attribute to use

haven't tried but should work. let me know pls

ralph_def...@yahoo.de


"chrysanhy" <phpli...@hyphusonline.com> wrote in message
news:88827b190908160033n226b370bqe2ab70732811...@mail.gmail.com...
> I have the following code to extract the URLs from the anchor tags of an
> HTML page:
>
> $html = new DOMDocument();
> $htmlpage->loadHtmlFile($location);
> $xpath = new DOMXPath($htmlpage);
> $links = $xpath->query( '//a' );
> foreach ($links as $link)
> { $int_url_list[$i++] = $link->getAttribute( 'href' ) . "\n"; }
>
> If I have a link <a href="http://X.com";>YYYY</a>, how do I extract the
> corresponding YYYY which is displayed to the user as the text of the link
> (if it's an image tag, I would like a DOMElement for that).
> Thanks
>



--- End Message ---
--- Begin Message ---
tedd wrote:
Hi gang:

Here's another exercise to consider.

This is a date entry problem where the user can enter a date in various forms, but the return will be in a consistent format.

For example, a user might enter a date in the form of:

August 5, 2009
Aug 05 2009
Aug 5, 9
08/05/09
8-5-9
8 05 2009
8,5,9

Or any combination thereof.

However, the resultant date will be standardized to: Aug 5, 2009.

Extra points for solving this for Euro as well as US date formats (i.e., 5 Aug, 2009 vs Aug 5, 2009). And, extra extra points for accommodating month brevity, such as "A" for August and "Mar" for March and so on.

But the real problem here is 05/08/09 is still August 5 2009 .....
So teaching customers to use 2009.08.05 removes the hassle of needing to know where your target site is based!

But as has been said, the real solution is a date picker.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
On Sun, 2009-08-16 at 08:36 +0100, Lester Caine wrote:
> tedd wrote:
> > Hi gang:
> > 
> > Here's another exercise to consider.
> > 
> > This is a date entry problem where the user can enter a date in various 
> > forms, but the return will be in a consistent format.
> > 
> > For example, a user might enter a date in the form of:
> > 
> > August 5, 2009
> > Aug 05 2009
> > Aug 5, 9
> > 08/05/09
> > 8-5-9
> > 8 05 2009
> > 8,5,9
> > 
> > Or any combination thereof.
> > 
> > However, the resultant date will be standardized to: Aug 5, 2009.
> > 
> > Extra points for solving this for Euro as well as US date formats (i.e., 
> > 5 Aug, 2009 vs Aug 5, 2009).  And, extra extra points for accommodating 
> > month brevity, such as "A" for August and "Mar" for March and so on.
> 
> But the real problem here is 05/08/09 is still August 5 2009 .....
> So teaching customers to use 2009.08.05 removes the hassle of needing to know 
> where your target site is based!
> 
> But as has been said, the real solution is a date picker.
> 
> -- 
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
> 

Seriously, go out and beat your clients over the head, and then hit them
about some more until they understand the folly of using bad date
formats. US-style dates are just the start of it!

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


--- End Message ---

Reply via email to