php-general Digest 13 Mar 2013 21:47:04 -0000 Issue 8161

Topics (messages 320506 through 320521):

Re: mysql custom global defined variable
        320506 by: Camilo Sperberg
        320515 by: Marco Behnke

Re: Generating CRUD code for normalized db
        320507 by: Gary
        320511 by: Jim Giner
        320513 by: Marco Behnke
        320514 by: Ashley Sheridan
        320516 by: Bastien Koert

imap_open use to read the sent mail using gmail
        320508 by: Kevin Peterson
        320509 by: TR Shaw

Traits - Is it stable to use get_class_methods on a trait?
        320510 by: NaMarPi

Re: Mystery foreach error
        320512 by: Jim Giner

Accessing Files Outside the Web Root
        320517 by: Dale H. Cook
        320518 by: Jen Rasmussen
        320519 by: Dan McCullough
        320520 by: Marc Guay
        320521 by: Dale H. Cook

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 Mar 13, 2013, at 10:35 AM, Kevin Peterson wrote:

> In my database design, I tend to store some variable that is meant to be 
> acting as a ROLE or TYPE as SMALLINT. For example : 
> 
>    CREATE TABLE `house` (
>       `id` int(11) NOT NULL AUTO_INCREMENT,
>       `type` smallint(11) NOT NULL,
>    )
> 
> 
> And in php, I do
> 
>    define('HOUSE_SMALL_TYPE', '0');
>    define('HOUSE_MEDIUM_TYPE', '1');
> 
> So in php, in SELECT queries I do :
> 
>    $this->db->query("SELECT * FROM house  
>                        WHERE type=?;", HOUSE_SMALL_TYPE);
> 
> My questions are : 
> 1. In the php part, is there is a better way to do this ? 
> 2. In the mysql itself, does mysql also has global define functionality (like 
> the define in php) ? I also want to do kind of SELECT * FROM house WHERE type 
> = HOUSE_SMALL_TYPE in mysql query.
> 


Question 1:
I see no possible improvements, you could however use an array with values 
instead of constants, but that's rather a personal choice as I don't like 
constants that much, unless you are on your own namespace.

My example implementation:

$houseTypes = array(
        'house_small_type' => 0,
        'house_medium_type' => 1,
        etc.
);

Question 2:
You could use ENUM data type, but it has quite a few disadvantages:
1- Translation could be tricky to implement
2- DDL shouldn't be used for data!
3- Updating or deleting values can leave your old records in an inconsistent 
state

You can also use SET to set variables, I've never used them but I think they 
could work in your case: 
http://dev.mysql.com/doc/refman/5.5/en/user-variables.html

Greetings.

--- End Message ---
--- Begin Message ---
Am 13.03.13 10:35, schrieb Kevin Peterson:
> In my database design, I tend to store some variable that is meant to be 
> acting as a ROLE or TYPE as SMALLINT. For example : 
>
>     CREATE TABLE `house` (
>        `id` int(11) NOT NULL AUTO_INCREMENT,
>        `type` smallint(11) NOT NULL,
>     )
>
>
> And in php, I do
>
>     define('HOUSE_SMALL_TYPE', '0');
>     define('HOUSE_MEDIUM_TYPE', '1');
>
> So in php, in SELECT queries I do :
>
>     $this->db->query("SELECT * FROM house  
>                         WHERE type=?;", HOUSE_SMALL_TYPE);
>
> My questions are : 
> 1. In the php part, is there is a better way to do this ? 

I stopped using define in favor of somehow "namespaced constants" as
const in classes. But basically there is no difference.
Advantages of using constants (which ever) are code completion to avoid
spelling errors. I see no possible improvements here.

> 2. In the mysql itself, does mysql also has global define functionality (like 
> the define in php) ? I also want to do kind of SELECT * FROM house WHERE type 
> = HOUSE_SMALL_TYPE in mysql query.

Maybe this is what you are looking for?
http://forums.mysql.com/read.php?98,273432,273432


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz


Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
ma...@behnke.biz wrote:

> Do us all a favor abnd stay away from open source if you do not honor
> the work
> us wannabes put into it.

As I said before "I wasn't aware you would feel that the cap fitted."
If you do feel that, then perhaps instead of complaining at me for
pointing it out, you would be better off employing that time increasing
the quality of what you produce.

-- 
Gary        Please do NOT send me 'courtesy' replies off-list.


--- End Message ---
--- Begin Message ---
On 3/13/2013 7:57 AM, Gary wrote:
ma...@behnke.biz wrote:

Do us all a favor abnd stay away from open source if you do not honor
the work
us wannabes put into it.

As I said before "I wasn't aware you would feel that the cap fitted."
If you do feel that, then perhaps instead of complaining at me for
pointing it out, you would be better off employing that time increasing
the quality of what you produce.

YOU ARE JUST NOT A NICE PERSON! Please go away until you learn to act like an adult.
--- End Message ---
--- Begin Message ---
Am 13.03.13 12:57, schrieb Gary:
> ma...@behnke.biz wrote:
>
>> Do us all a favor abnd stay away from open source if you do not honor
>> the work
>> us wannabes put into it.
> As I said before "I wasn't aware you would feel that the cap fitted."
> If you do feel that, then perhaps instead of complaining at me for
> pointing it out, you would be better off employing that time increasing
> the quality of what you produce.
>
So you said you tried Yii. But have you wasted some of your precious
time trying out the extension that "extends" Yii in a way, that creating
models and views with Gii get proper SELECT Boxes and stuff for
relations? If I understood you correct, this is what you were looking for?

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz


Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
On Wed, 2013-03-13 at 19:24 +0100, Marco Behnke wrote:

> Am 13.03.13 12:57, schrieb Gary:
> > ma...@behnke.biz wrote:
> >
> >> Do us all a favor abnd stay away from open source if you do not honor
> >> the work
> >> us wannabes put into it.
> > As I said before "I wasn't aware you would feel that the cap fitted."
> > If you do feel that, then perhaps instead of complaining at me for
> > pointing it out, you would be better off employing that time increasing
> > the quality of what you produce.
> >
> So you said you tried Yii. But have you wasted some of your precious
> time trying out the extension that "extends" Yii in a way, that creating
> models and views with Gii get proper SELECT Boxes and stuff for
> relations? If I understood you correct, this is what you were looking for?
> 


At this point I don't think he's looking for an actual solution, but
merely wants to moan about open source. OSS has flaws, of course, but
even someone so narrow minded would have a hard time arguing in earnest
that it suffered from too little choice and a lack of solutions to a
problem.

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



--- End Message ---
--- Begin Message ---
On Wed, Mar 13, 2013 at 2:55 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Wed, 2013-03-13 at 19:24 +0100, Marco Behnke wrote:
>
>> Am 13.03.13 12:57, schrieb Gary:
>> > ma...@behnke.biz wrote:
>> >
>> >> Do us all a favor abnd stay away from open source if you do not honor
>> >> the work
>> >> us wannabes put into it.
>> > As I said before "I wasn't aware you would feel that the cap fitted."
>> > If you do feel that, then perhaps instead of complaining at me for
>> > pointing it out, you would be better off employing that time increasing
>> > the quality of what you produce.
>> >
>> So you said you tried Yii. But have you wasted some of your precious
>> time trying out the extension that "extends" Yii in a way, that creating
>> models and views with Gii get proper SELECT Boxes and stuff for
>> relations? If I understood you correct, this is what you were looking for?
>>
>
>
> At this point I don't think he's looking for an actual solution, but
> merely wants to moan about open source. OSS has flaws, of course, but
> even someone so narrow minded would have a hard time arguing in earnest
> that it suffered from too little choice and a lack of solutions to a
> problem.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

Two minutes with google got me this:

http://www.codegravity.com/programming/orm-object-relational-mapping-frameworks-php

It seems that propel ( http://www.propelorm.org/ ) and CoughPHP (
http://coughphp.com/ ) both offer code generation

-- 

Bastien

Cat, the other other white meat

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

I am using imap_open 
("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox, $user, pass) but 
want to access gmail sent box not the inbox. Please suggest how to proceed. 

Thanks


--- End Message ---
--- Begin Message ---
On Mar 13, 2013, at 10:20 AM, Kevin Peterson wrote:

> Hi, 
> 
> I am using imap_open 
> ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox, $user, pass) but 
> want to access gmail sent box not the inbox. Please suggest how to proceed. 
> 

Use

$mboxes = imap_getmailboxes($imap, 
"{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}, "*");
print_r($mboxes);

To find mailbox names.

Tom


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

there is a trait which sits in a class. I need the names of the trait methods,
and get_class_methods does this job.
I am happy with that, but is it safe/stable? Is there a better way to get trait 
method names?

Thanks a lot.



Working example (My_Class and My_Trait are in different files):.

----------------------------------------------------------------------------------------------

trait My_Trait {
    function trait_method_1() {}

    function trait_method_2() {}
}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

class My_Class {
    use My_Trait;

    function class_method_1() {
        $trait_methods = get_class_methods( 'My_Trait' );
        print_r( $trait_methods );
    }
    function class_method_2() {}
}

$my_object = new My_Class();
$my_object->class_method_1();


Result:
------------------------
[13-Mar-2013 14:41:22 UTC] Array
(
    [0] => trait_method_1
    [1] => trait_method_2
)


--- End Message ---
--- Begin Message ---
On 3/12/2013 9:04 PM, Angela Barone wrote:
On Mar 12, 2013, at 5:16 PM, David Robley wrote:
Presumably there is a fixed list of State - those are US states? -

so why not provide a drop down list of the possible choices?

        There is, but the problem must have been that if someone didn't select a State, 
$state was blank.  I've since given the "Select a State..." choice a value of 
'XX' and I'm now looking for that in the if statement I mentioned before.

Angela

Why not just check if the $state exists as a key of the array $states before doing this?
--- End Message ---
--- Begin Message ---
Let me preface my question by noting that I am virtually a PHP novice. Although 
I am a long-time webmaster, and have used PHP for some years to give visitors 
access to information in my SQL database, this is my first attempt to use it 
for another purpose. I have browsed the mailing list archives and have searched 
online but have not yet succeeded in teaching myself how to do what I want to 
do. This need not provoke a lengthy discussion or involve extensive 
hand-holding - if someone can point to an appropriate code sample or online 
tutorial that might do the trick.

I am the author of a number of PDF files that serve as genealogical reference 
works. My problem is that there are a number of sites which are posing as 
search engines and which display my PDF files in their entirety on their own 
sites. These pirate sites are not simply opening a window that displays my 
files as they appear on my site. They are using Google Docs to display copies 
of my files that are cached or stored elsewhere online. The proof of that is 
that I can modify one of my files and upload it to my site. The file, as seen 
on my site, immediately displays the modification. The same file, as displayed 
on the pirate sites, is unmodified and may remain unmodified for weeks.

It is obvious that my files, which are stored under public_html, are being 
spidered and then stored or cached. This displeases me greatly. I want my 
files, some of which have cost an enormous amount of work over many years, to 
be available only on my site. Legitimate search engines, such as Google, may 
display a snippet, but they do not display the entire file - they link to my 
site so the visitor can get the file from me.

A little study has indicated to me that if I store those files in a folder 
outside the web root and use PHP to provide access they will not be spidered. 
Writing a PHP script to provide access to the files in that folder is what I 
need help with. I have experimented with a number of code samples but have not 
been able to make things work. Could any of you point to code samples or 
tutorials that might help me? Remember that, aside from the code I have written 
to handle my SQL database I am a PHP novice.

Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants;
Plymouth Co. MA Coordinator for the USGenWeb Project
Administrator of http://plymouthcolony.net 


--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Dale H. Cook [mailto:radiot...@plymouthcolony.net] 
Sent: Wednesday, March 13, 2013 3:38 PM
To: php-gene...@lists.php.net
Subject: [PHP] Accessing Files Outside the Web Root

Let me preface my question by noting that I am virtually a PHP novice.
Although I am a long-time webmaster, and have used PHP for some years to
give visitors access to information in my SQL database, this is my first
attempt to use it for another purpose. I have browsed the mailing list
archives and have searched online but have not yet succeeded in teaching
myself how to do what I want to do. This need not provoke a lengthy
discussion or involve extensive hand-holding - if someone can point to an
appropriate code sample or online tutorial that might do the trick.

I am the author of a number of PDF files that serve as genealogical
reference works. My problem is that there are a number of sites which are
posing as search engines and which display my PDF files in their entirety on
their own sites. These pirate sites are not simply opening a window that
displays my files as they appear on my site. They are using Google Docs to
display copies of my files that are cached or stored elsewhere online. The
proof of that is that I can modify one of my files and upload it to my site.
The file, as seen on my site, immediately displays the modification. The
same file, as displayed on the pirate sites, is unmodified and may remain
unmodified for weeks.

It is obvious that my files, which are stored under public_html, are being
spidered and then stored or cached. This displeases me greatly. I want my
files, some of which have cost an enormous amount of work over many years,
to be available only on my site. Legitimate search engines, such as Google,
may display a snippet, but they do not display the entire file - they link
to my site so the visitor can get the file from me.

A little study has indicated to me that if I store those files in a folder
outside the web root and use PHP to provide access they will not be
spidered. Writing a PHP script to provide access to the files in that folder
is what I need help with. I have experimented with a number of code samples
but have not been able to make things work. Could any of you point to code
samples or tutorials that might help me? Remember that, aside from the code
I have written to handle my SQL database I am a PHP novice.

Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants;
Plymouth Co. MA Coordinator for the USGenWeb Project Administrator of
http://plymouthcolony.net 


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


Have you tried keeping all of your documents in one directory and blocking
that directory via a robots.txt file?

Jen





--- End Message ---
--- Begin Message ---
Web bots can ignore the robots.txt file, most scrapers would.
On Mar 13, 2013 4:59 PM, "Jen Rasmussen" <j...@cetaceasound.com> wrote:

> -----Original Message-----
> From: Dale H. Cook [mailto:radiot...@plymouthcolony.net]
> Sent: Wednesday, March 13, 2013 3:38 PM
> To: php-gene...@lists.php.net
> Subject: [PHP] Accessing Files Outside the Web Root
>
> Let me preface my question by noting that I am virtually a PHP novice.
> Although I am a long-time webmaster, and have used PHP for some years to
> give visitors access to information in my SQL database, this is my first
> attempt to use it for another purpose. I have browsed the mailing list
> archives and have searched online but have not yet succeeded in teaching
> myself how to do what I want to do. This need not provoke a lengthy
> discussion or involve extensive hand-holding - if someone can point to an
> appropriate code sample or online tutorial that might do the trick.
>
> I am the author of a number of PDF files that serve as genealogical
> reference works. My problem is that there are a number of sites which are
> posing as search engines and which display my PDF files in their entirety
> on
> their own sites. These pirate sites are not simply opening a window that
> displays my files as they appear on my site. They are using Google Docs to
> display copies of my files that are cached or stored elsewhere online. The
> proof of that is that I can modify one of my files and upload it to my
> site.
> The file, as seen on my site, immediately displays the modification. The
> same file, as displayed on the pirate sites, is unmodified and may remain
> unmodified for weeks.
>
> It is obvious that my files, which are stored under public_html, are being
> spidered and then stored or cached. This displeases me greatly. I want my
> files, some of which have cost an enormous amount of work over many years,
> to be available only on my site. Legitimate search engines, such as Google,
> may display a snippet, but they do not display the entire file - they link
> to my site so the visitor can get the file from me.
>
> A little study has indicated to me that if I store those files in a folder
> outside the web root and use PHP to provide access they will not be
> spidered. Writing a PHP script to provide access to the files in that
> folder
> is what I need help with. I have experimented with a number of code samples
> but have not been able to make things work. Could any of you point to code
> samples or tutorials that might help me? Remember that, aside from the code
> I have written to handle my SQL database I am a PHP novice.
>
> Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants;
> Plymouth Co. MA Coordinator for the USGenWeb Project Administrator of
> http://plymouthcolony.net
>
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>
> Have you tried keeping all of your documents in one directory and blocking
> that directory via a robots.txt file?
>
> Jen
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
> Have you tried keeping all of your documents in one directory and blocking
> that directory via a robots.txt file?

These don't sound like robots that would respect a txt file to me.

--- End Message ---
--- Begin Message ---
At 04:58 PM 3/13/2013, Jen Rasmussen wrote:

>Have you tried keeping all of your documents in one directory and blocking
>that directory via a robots.txt file?

A spider used by a pirate site does not have to honor robots.txt, just as a 
non-Adobe PDF utility does not have to honor security settings imposed by 
Acrobat Pro. The use of robots.txt would succeed mainly in blocking major 
search engines, which are not the problem.

Dale H. Cook, Member, NEHGS and MA Society of Mayflower Descendants;
Plymouth Co. MA Coordinator for the USGenWeb Project
Administrator of http://plymouthcolony.net  


--- End Message ---

Reply via email to