php-general Digest 17 Aug 2009 05:24:10 -0000 Issue 6289

2009-08-16 Thread php-general-digest-help

php-general Digest 17 Aug 2009 05:24:10 - Issue 6289

Topics (messages 296836 through 296865):

Re: Issue with the huge import script
296836 by: Phpster

Re: How do I extract link text from anchor tag as well as the URL from the 
"href" attribute
296837 by: chrysanhy
296839 by: Ralph Deffke
296840 by: Ralph Deffke
296841 by: chrysanhy
296842 by: chrysanhy
296846 by: Ralph Deffke
296847 by: Ralph Deffke
296858 by: chrysanhy

Dan Brown
296838 by: Angus Mann
296844 by: Per Jessen

Cannot exec in my own directory
296843 by: Dotan Cohen
296845 by: Sudheer Satyanarayana
296850 by: Dotan Cohen
296852 by: Caner Bulut
296856 by: Dotan Cohen

Sanitizing mysql inserts of user data
296848 by: Dotan Cohen
296851 by: Caner Bulut
296853 by: Adam Randall
296854 by: Dotan Cohen
296855 by: Dotan Cohen

brainstorm/samples on _autoload() needed
296849 by: Ralph Deffke

Re: Another date exercise
296857 by: Paul M Foster
296860 by: Ralph Deffke

running str_replace, it misbehaves!
296859 by: Allen McCabe

 to a css file requires .css ???
296861 by: Daniel Kolbo
296862 by: Nitsan Bin-Nun
296863 by: Daniel Kolbo
296864 by: Adam Shannon

Re: File or directory?
296865 by: George Langley

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 Aug 15, 2009, at 9:15 PM, Devendra Jadhav   
wrote:



Hi,

I have to import data from one database to another, I have to import  
around

10(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


What are the databases? Both mysql? Or different systems? How do you  
define whether the record exists?


Are you running into timeout issues? If so, one trick is to write the  
page to process 100 or so records at a time and then use JavaScript to  
reload the page to avoid the timeout issues.


Bastien

Sent from my iPod

--- End Message ---
--- Begin Message ---
It did not work. Both gave me a "Call to undefined method" fatal error.

On Sun, Aug 16, 2009 at 1:43 AM, Ralph Deffke  wrote:

>
> try
>
> $link->nodeValue()
>
> or
>
> $link->getContent()
>
> im not shure which one works on an image link which is indeed a child of  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"  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 http://X.com";>, how do I extract the
> > corresponding  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
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
did u try it something like this

foreach ($links as $link) {
$int_url_list[$i]["href"] = $link->getAttribute( 'href' );
$int_url_list[$i++]["linkText"] = $link->getContent(  ); // nodeValue();
}
that should work

send ur code then please
ralph_def...@yahoo,de


"chrysanhy"  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 $

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

2009-08-16 Thread php-general-digest-help

php-general Digest 16 Aug 2009 10:52:53 - 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"  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
10(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 10+ 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"  wrote in message
news:be4b00cf0908151815r1c7430d2j8a6cb0da1f10a...@mail.gmail.com...
> Hi,
>
> I have to import data from one database to another, I have to import
around
> 10(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_