php-general Digest 2 Mar 2012 19:03:00 -0000 Issue 7710

Topics (messages 316834 through 316850):

Re: Nested database loops and completing an unordered list....
        316834 by: Jay Blanchard
        316840 by: Jim Lucas
        316842 by: Bastien Koert
        316843 by: Jay Blanchard
        316849 by: Jay Blanchard
        316850 by: Jim Lucas

curl equivalent in PHP
        316835 by: Nibin V M
        316836 by: Marc Guay
        316837 by: Nibin V M
        316838 by: Nibin V M
        316839 by: FeIn
        316841 by: Jim Lucas
        316844 by: Nibin V M
        316845 by: Micky Hulse
        316846 by: Daniel Brown
        316848 by: Nibin V M

problem about PHP-FPM in TCP socket and Unix socket
        316847 by: Yuchen Wang

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 ---
> My usual approach to a problem like this to to includes a parent column in 
> the table
> 
> ID (int pk)
> Parent ( default null ) // no parent
> Item
> Itemtype
> [etc]
> 
> Parent will then hold either a null if a top level item, or a structured path 
> ( 1/10/24 ) that notes the parents of the item all the way up to the parent. 
> That way, a single query will get you all items in that parent's lineage to 
> whatever depth is needed by using the child's value
> 
> Select * from table where parent = '1/10' 
> 
> Would retrieve all items that are children of a top level of 1 and a second 
> level of 10

I would do that under normal circumstance but I cannot modify the client's 
table in any way shape or form. I am considering the COMPANY_ID to be the 
parent at this point and I can get all who belong to a company. I just need to 
turn that lineage into a tree.

--- End Message ---
--- Begin Message ---
On 03/01/2012 06:20 PM, Jay Blanchard wrote:
[snip]
Can you show the output of the function above?
[/snip]


Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set?

At this point, I don't believe you have shown your output. Please show the output of your function.

0
SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3'
Executives and Management

Normally this query alone returns 9 rows of data. Each of these rows should be 
included in the next query where TIER1DATA = each of the nine in succession

1
SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER1DATA` = 'Executives and Management'
  Executives and ManagementLeadership
2
SELECT DISTINCT `TIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER2DATA` = 'Executives and ManagementLeadership'
   Executives and ManagementLeadershipManager
3
SELECT DISTINCT `BUSTIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `TIER3DATA` = 'Executives and ManagementLeadershipManager'
    Knee
4
SELECT DISTINCT `BUSTIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER1DATA` = 'Knee'
     KneeDIV01
5
SELECT DISTINCT `BUSTIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER2DATA` = 'KneeDIV01'
      KneeDIV01DEPT02
6
SELECT DISTINCT `BUSTIER4DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER3DATA` = 'KneeDIV01DEPT02'
       KneeDIV01DEPT02GRP04
7
SELECT DISTINCT `` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`BUSTIER4DATA` = 'KneeDIV01DEPT02GRP04'
1054    Unknown column '' in 'field list'


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--- End Message ---
--- Begin Message ---
On Fri, Mar 2, 2012 at 7:43 AM, Jay Blanchard
<jay.blanch...@sigmaphinothing.org> wrote:
>> My usual approach to a problem like this to to includes a parent column in 
>> the table
>>
>> ID (int pk)
>> Parent ( default null ) // no parent
>> Item
>> Itemtype
>> [etc]
>>
>> Parent will then hold either a null if a top level item, or a structured 
>> path ( 1/10/24 ) that notes the parents of the item all the way up to the 
>> parent. That way, a single query will get you all items in that parent's 
>> lineage to whatever depth is needed by using the child's value
>>
>> Select * from table where parent = '1/10'
>>
>> Would retrieve all items that are children of a top level of 1 and a second 
>> level of 10
>
> I would do that under normal circumstance but I cannot modify the client's 
> table in any way shape or form. I am considering the COMPANY_ID to be the 
> parent at this point and I can get all who belong to a company. I just need 
> to turn that lineage into a tree.


Would they let you make a copy or a join table where you could build
what you need? Then maybe add a stored proc to move data as needed
-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
[snip]
Doesn't this SQL query return everything that has company_id set to 3 which would it not contain all the data from the other queries combined into one large data set?
[/snip]

I could do that, I can return one large dataset for all of the columns shown in the tiers array. I have to remove the DISTINCT's. When I return that dataset in this case I return seven columns of data with the parent being in the leftmost column and descending to the right. The goal with the the recursive function was to get each descendant line so that it could be formatted in a nested unordered list. So in the SQL below you get 9 records. For each of the 9 records you could get any number of children depending on which of the 9 you're looking at. Then for each of those children you could get their descendants and so on.

I was doing it the long way at first, until a recursive function was suggested. The problem that I was having there was formatting the <ul>'s and <li>'s properly.

Now I feel as if I am really close to a better solution than the brute force method. I may just be a little too frustrated to see what is a simple answer.

Thanks for your help!




At this point, I don't believe you have shown your output. Please show the output of your function.

0
SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3'
Executives and Management

Normally this query alone returns 9 rows of data. Each of these rows should be included in the next query where TIER1DATA = each of the nine in succession

1
SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER1DATA` = 'Executives and Management'
  Executives and ManagementLeadership


--- End Message ---
--- Begin Message ---
[snip] ...stuff ... [/snip]

A thought occurred to me - I need to call the function at the end of the while loop and then again with different criteria after the while loop? I'll have to test that later today.
--- End Message ---
--- Begin Message ---
On 03/02/2012 08:27 AM, Jay Blanchard wrote:
[snip]
Doesn't this SQL query return everything that has company_id set to 3
which would it not contain all the data from the other queries combined
into one large data set?
[/snip]

I could do that, I can return one large dataset for all of the columns
shown in the tiers array. I have to remove the DISTINCT's. When I return
that dataset in this case I return seven columns of data with the parent
being in the leftmost column and descending to the right. The goal with
the the recursive function was to get each descendant line so that it
could be formatted in a nested unordered list. So in the SQL below you
get 9 records. For each of the 9 records you could get any number of
children depending on which of the 9 you're looking at. Then for each of
those children you could get their descendants and so on.

I was doing it the long way at first, until a recursive function was
suggested. The problem that I was having there was formatting the <ul>'s
and <li>'s properly.

I'm not saying you should get rid of the recursive function calls, but rather, why not pull all your data in one SQL call, then use recursive functions on the returned array of data. It will save a little time by not hitting the DB on each function call too.


Now I feel as if I am really close to a better solution than the brute
force method. I may just be a little too frustrated to see what is a
simple answer.

Thanks for your help!


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--- End Message ---
--- Begin Message ---
Hello,

I am trying to display the website content through a php code ( my own
websites; doesn't cause copy right issues ).

I use curl to display the page via the following simple code.

<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://mytest.com";);
curl_exec ($curl);
curl_close ($curl);
?>

But on some of my servers, curl isn't enabled! Is there any equivalent code
to  achieve the same?

Thank you,

-- 
Regards....

Nibin.

http://TechsWare.in

--- End Message ---
--- Begin Message ---
http://simplehtmldom.sourceforge.net/

--- End Message ---
--- Begin Message ---
Thanks Marc. But that need to add the DOM parser to the server. What I am
looking for something like "iframe" in html and that doesn't require any
additional PHP modules ( I do would like to avoid additions to the current
php; that is why I didn't compiled in curl )

On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay <marc.g...@gmail.com> wrote:

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


-- 
Regards....

Nibin.

http://TechsWare.in

--- End Message ---
--- Begin Message ---
Thanks Marc. But that need to add the DOM parser to the server. What I am
looking for something like "iframe" in html and that doesn't require any
additional PHP modules ( I do would like to avoid additions to the current
php; that is why I didn't compiled in curl )

On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M <nibi...@gmail.com> wrote:

> Thanks Marc. But that need to add the DOM parser to the server. What I am
> looking for something like "iframe" in html and that doesn't require any
> additional PHP modules ( I do would like to avoid additions to the current
> php; that is why I didn't compiled in curl )
>
>
> On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay <marc.g...@gmail.com> wrote:
>
>> http://simplehtmldom.sourceforge.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Regards....
>
> Nibin.
>
> http://TechsWare.in
>
>


-- 
Regards....

Nibin.

http://TechsWare.in

--- End Message ---
--- Begin Message ---
http://www.php.net/manual/en/function.stream-context-create.php

On Fri, Mar 2, 2012 at 4:44 PM, Nibin V M <nibi...@gmail.com> wrote:

> Thanks Marc. But that need to add the DOM parser to the server. What I am
> looking for something like "iframe" in html and that doesn't require any
> additional PHP modules ( I do would like to avoid additions to the current
> php; that is why I didn't compiled in curl )
>
> On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M <nibi...@gmail.com> wrote:
>
> > Thanks Marc. But that need to add the DOM parser to the server. What I am
> > looking for something like "iframe" in html and that doesn't require any
> > additional PHP modules ( I do would like to avoid additions to the
> current
> > php; that is why I didn't compiled in curl )
> >
> >
> > On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay <marc.g...@gmail.com> wrote:
> >
> >> http://simplehtmldom.sourceforge.net/
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> > --
> > Regards....
> >
> > Nibin.
> >
> > http://TechsWare.in
> >
> >
>
>
> --
> Regards....
>
> Nibin.
>
> http://TechsWare.in
>

--- End Message ---
--- Begin Message ---
On 03/02/2012 06:26 AM, Nibin V M wrote:
Hello,

I am trying to display the website content through a php code ( my own
websites; doesn't cause copy right issues ).

I use curl to display the page via the following simple code.

<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://mytest.com";);
curl_exec ($curl);
curl_close ($curl);
?>

But on some of my servers, curl isn't enabled! Is there any equivalent code
to  achieve the same?

Thank you,


As long as you do not need to perform posts to the other website via the PHP request, you could include, file_get_contents, fopen + fread, etc...

All you need to make sure is that allow_url_fopen is enabled.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--- End Message ---
--- Begin Message ---
Thanks guys :)

Now another problem...I use a test domain ( say blahblah.com ) for testing
this, which isn't registered yet. So with the given code the index page is
loading fine. But when I try to click on any links, it will redirect to the
original domain which isn't exists!

( I have actually pointed the test domain to my server via hosts file on
the server )

So I wanted to browse the website via a PHP script, same as if I use a
browser on the server.

Hope you get me! :)

Is there any way to achieve this via PHP?

What I wanted to

On Fri, Mar 2, 2012 at 9:37 PM, Jim Lucas <li...@cmsws.com> wrote:

> On 03/02/2012 06:26 AM, Nibin V M wrote:
>
>> Hello,
>>
>> I am trying to display the website content through a php code ( my own
>> websites; doesn't cause copy right issues ).
>>
>> I use curl to display the page via the following simple code.
>>
>> <?php
>> $curl = curl_init();
>> curl_setopt ($curl, CURLOPT_URL, "http://mytest.com";);
>> curl_exec ($curl);
>> curl_close ($curl);
>> ?>
>>
>> But on some of my servers, curl isn't enabled! Is there any equivalent
>> code
>> to  achieve the same?
>>
>> Thank you,
>>
>>
> As long as you do not need to perform posts to the other website via the
> PHP request, you could include, file_get_contents, fopen + fread, etc...
>
> All you need to make sure is that allow_url_fopen is enabled.
>
> --
> Jim Lucas
>
> http://www.cmsws.com/
> http://www.cmsws.com/examples/
> http://www.bendsource.com/
>



-- 
Regards....

Nibin.

http://TechsWare.in

--- End Message ---
--- Begin Message ---
Hello,

On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas <li...@cmsws.com> wrote:
>> But on some of my servers, curl isn't enabled! Is there any equivalent
>> code
>> to  achieve the same?

I've used a combination of output buffering [1], readfile() [2] and
caching (specific to the framework I was using).

Simply, you could resort to:

<?php readfile('http://www.google.com'); ?>

Ofc, the links would need to be absolute in order for the assets to load.

Good luck!

Cheers,
Micky

    [1] php.net/ob-start
    [2] php.net/readfile

--- End Message ---
--- Begin Message ---
On Fri, Mar 2, 2012 at 11:29, Nibin V M <nibi...@gmail.com> wrote:
> Thanks guys :)
>
> Now another problem...I use a test domain ( say blahblah.com ) for testing
> this, which isn't registered yet. So with the given code the index page is
> loading fine. But when I try to click on any links, it will redirect to the
> original domain which isn't exists!

<?php
echo 
str_replace('blahblah.com','localhost',file_get_contents('remote-domain.example.com'));
?>

    Modify it as needed, and if you want to surf the site using the
script as a proxy, add the logic to handle that.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Hmm..I am a php newbie ( just started learning it )...

what my need is to display website from my server always for a
non-registered domain.This is the code I use now to display the website

<?php
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

$fp = fopen('http://www.blahblah.com', 'r', false, $context);
fpassthru($fp);
fclose($fp);
?>

Of course blahblah.com isn't registered yet. This will load the index page
of blahblah.com fine ( since I use hosts file to resolve blahblah.com on
the server ). But if we click on any link, it will give "server not found"
error since my "local machine" is trying to resolve blahblah.com this time.
I need to avoid it and want to load my domain "always" from the server when
I click any link on the webpage, etc .

How can I modify the above code to make it work! If possible, I request
somebody to tell me the exact code that I need to change in the above
script - since most of the php part is still greek to me :)

Thank you,



On Fri, Mar 2, 2012 at 10:09 PM, Micky Hulse <rgmi...@gmail.com> wrote:

> Hello,
>
> On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas <li...@cmsws.com> wrote:
> >> But on some of my servers, curl isn't enabled! Is there any equivalent
> >> code
> >> to  achieve the same?
>
> I've used a combination of output buffering [1], readfile() [2] and
> caching (specific to the framework I was using).
>
> Simply, you could resort to:
>
> <?php readfile('http://www.google.com'); ?>
>
> Ofc, the links would need to be absolute in order for the assets to load.
>
> Good luck!
>
> Cheers,
> Micky
>
>    [1] php.net/ob-start
>    [2] php.net/readfile
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards....

Nibin.

http://TechsWare.in

--- End Message ---
--- Begin Message ---
Hello all,

I am trying to config some new server

All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and
php-fpm before

But, I run ab(ab -n 20000 -c50 http://192.168.74.130:81/) to test the
performance of Unix Socket and TCP Socket,
the result is Unix is little better than TCP

Usually we run php and web server in the same server,
So, TCP socket and Unix socket
Which method do you prefer ?

Thank you

-- 
*Yuchen Wang*

--- End Message ---

Reply via email to