Re: [PHP-DB] functions, the best way to implement and arrange them..

2011-07-13 Thread Tamara Temple


On Jul 12, 2011, at 7:28 AM, Taco Mathijs Hillenaar-Meerveld wrote:

It might be a simple question for the local die-hards among here,  
but i'm

really wondering about how
developers arrange their scripts and keep their map structures.

today i was looking for the best way to keep my scripts clear and to  
put

them into maps so i have a clear overview.
the same thing i would do for the scripts, using the functions i  
have and

throwing them in 1 or more php documents.

i can not find it how it should be done. is it a good idea to put a  
couple

of functions in just 1 document?
like sessions and login/logout functions?

in my idea i would only need to include a document in the header of my
website and then i'm done, right?

some thoughts, ideas and tips would be appreciated.

kind regards

taco


Arranging functions, classes, and such into files is something that  
we've used in software engineering for a long, long time. There are  
some general concepts:


* Keep your files fairly small and concise. Don't put everything in  
one file.
* The contents of your files should be logically consistent. Group  
functions which work on similar sets of data, or do similar tasks,  
together.
* Classes are a great way to go with grouping functions that act on a  
cohesive set of data. Generally, one class per file is a good rule of  
thumb, although there are also cases for including more than one class  
in a single file.
* Functions and methods should be cohesive; they should do only one  
thing. You can have several functions in a file, and you should have  
several methods in a class.
* Grouping functions temporaly is generally a bad idea. The conceptual  
exception to this is having a single configuration file for setting up  
variables in the program that might vary with installation. This isn't  
really arranging functions, though, as it's generally just setting and  
initializing data for the application.
* When you are writing functions and classes, work to make them  
general case and reusable as much as possible
* It's okay to have included files include other files; in fact, this  
is generally How It's Done. Remember to use include_once and  
require_once where appropriate.


Some reasonable chunks of files:
* session handling - it's nice to include all your session handling in  
one file, this is where you may want to set up a class and instantiate  
it.
* database access - also nice to be able to abstract out database  
setup and calls
* database migration - another area that can easily be separated from  
the whole
* models - each piece of business logic would be a good fit for a  
separate class and/or file
* views - keeping with the tradition of separating logic from  
presentation, keeping the code for presenting the page in separate  
files is also a good idea
* authorization and access control - if you choose to write your own,  
keeping it separate from the rest of your application is a great idea.

* data manipulation, string formatting, special processing



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



Re: [PHP-DB] functions, the best way to implement and arrange them..

2011-07-13 Thread Gunawan Wibisono
using function is good.. I like to use it in my script.. but I do think
about you should use Class because Class make your script more structure..
and you can hide your setting to make everyone unable to see or hack you
system..

example.. I always like to use bla then i built function h1($s)

actualy use function for simple task.. for moderate or complex.. use class

dev arrange the script because they know the flow and that can be have if
they experience 1-3 project or more. not something easy actualy

On Tue, Jul 12, 2011 at 7:28 PM, Taco Mathijs Hillenaar-Meerveld <
tm.hillen...@gmail.com> wrote:

> It might be a simple question for the local die-hards among here, but i'm
> really wondering about how
> developers arrange their scripts and keep their map structures.
>
> today i was looking for the best way to keep my scripts clear and to put
> them into maps so i have a clear overview.
> the same thing i would do for the scripts, using the functions i have and
> throwing them in 1 or more php documents.
>
> i can not find it how it should be done. is it a good idea to put a couple
> of functions in just 1 document?
> like sessions and login/logout functions?
>
> in my idea i would only need to include a document in the header of my
> website and then i'm done, right?
>
> some thoughts, ideas and tips would be appreciated.
>
> kind regards
>
> taco
>



-- 
akan ada dimana mulut terkunci dan suara tak ada lagi..
saat itu gunakanlah HP untuk melakukan SMS!!
-> ini aliran bedul.. bukan aliran aneh.
tertawa sebelum tertawa didepan RSJ..


Re: [PHP-DB] functions, the best way to implement and arrange them..

2011-07-13 Thread Karl DeSaulniers

On Jul 13, 2011, at 3:09 AM, Taco Mathijs Hillenaar-Meerveld wrote:

yes, it was a structure like that i was looking for. so a class is  
a group

of functions?
i have heard about 'wrappers' to and from what i've heard it is the  
same

thing?


On Tue, Jul 12, 2011 at 11:36 PM, Karl DeSaulniers  
wrote:




On Jul 12, 2011, at 7:28 AM, Taco Mathijs Hillenaar-Meerveld wrote:

 It might be a simple question for the local die-hards among here,  
but i'm

really wondering about how
developers arrange their scripts and keep their map structures.

today i was looking for the best way to keep my scripts clear and  
to put

them into maps so i have a clear overview.
the same thing i would do for the scripts, using the functions i  
have and

throwing them in 1 or more php documents.

i can not find it how it should be done. is it a good idea to put  
a couple

of functions in just 1 document?
like sessions and login/logout functions?

in my idea i would only need to include a document in the header  
of my

website and then i'm done, right?

some thoughts, ideas and tips would be appreciated.

kind regards

taco




Hi T,
One way I've found is to set up separate pages.
session.php
database.php
forms.php
etc..

Then in each you create a class named the same

EG for session.php


Then call on, say, the username var from a page.

Eg: view_acct.php

...

...


A very loose example, but hope it puts you on a good path..
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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





I would venture to say a class is much more then a wrapper.
but basically setting your back-end pages as classes to control  
everything with.
Makes referencing things in your front end much easier too, since  
most of the nuts and bolts are
in the classes. Yes classes have many functions inside them. whatever  
you want to use,
but there is a somewhat strict structure your classes have to be  
built in for them to work properly.


I would google something like "php class example" or "php class  
structure" or "php pages as classes"

That would probably yield some good reads.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] functions, the best way to implement and arrange them..

2011-07-13 Thread Taco Mathijs Hillenaar-Meerveld
yes, it was a structure like that i was looking for. so a class is a group
of functions?
i have heard about 'wrappers' to and from what i've heard it is the same
thing?


On Tue, Jul 12, 2011 at 11:36 PM, Karl DeSaulniers wrote:

>
> On Jul 12, 2011, at 7:28 AM, Taco Mathijs Hillenaar-Meerveld wrote:
>
>  It might be a simple question for the local die-hards among here, but i'm
>> really wondering about how
>> developers arrange their scripts and keep their map structures.
>>
>> today i was looking for the best way to keep my scripts clear and to put
>> them into maps so i have a clear overview.
>> the same thing i would do for the scripts, using the functions i have and
>> throwing them in 1 or more php documents.
>>
>> i can not find it how it should be done. is it a good idea to put a couple
>> of functions in just 1 document?
>> like sessions and login/logout functions?
>>
>> in my idea i would only need to include a document in the header of my
>> website and then i'm done, right?
>>
>> some thoughts, ideas and tips would be appreciated.
>>
>> kind regards
>>
>> taco
>>
>
>
> Hi T,
> One way I've found is to set up separate pages.
> session.php
> database.php
> forms.php
> etc..
>
> Then in each you create a class named the same
>
> EG for session.php
>  class Session
> {
>/session vars
>var $username = "";
>
>function Session(){
>  //constructor
>}
>//call your different session functions
>//set username for eg.
> }
> $session = new Session;
> ?>
>
> Then call on, say, the username var from a page.
>
> Eg: view_acct.php
>  
> ...
> 
> ...
> 
>
> A very loose example, but hope it puts you on a good path..
> Best,
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DB] functions, the best way to implement and arrange them..

2011-07-12 Thread Karl DeSaulniers


On Jul 12, 2011, at 7:28 AM, Taco Mathijs Hillenaar-Meerveld wrote:

It might be a simple question for the local die-hards among here,  
but i'm

really wondering about how
developers arrange their scripts and keep their map structures.

today i was looking for the best way to keep my scripts clear and  
to put

them into maps so i have a clear overview.
the same thing i would do for the scripts, using the functions i  
have and

throwing them in 1 or more php documents.

i can not find it how it should be done. is it a good idea to put a  
couple

of functions in just 1 document?
like sessions and login/logout functions?

in my idea i would only need to include a document in the header of my
website and then i'm done, right?

some thoughts, ideas and tips would be appreciated.

kind regards

taco



Hi T,
One way I've found is to set up separate pages.
session.php
database.php
forms.php
etc..

Then in each you create a class named the same

EG for session.php


Then call on, say, the username var from a page.

Eg: view_acct.php

...

...


A very loose example, but hope it puts you on a good path..
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



RE: [PHP-DB] Functions

2004-11-23 Thread Bastien Koert
http://ca.php.net/manual/en/function.substr-count.php
From: Yemi Obembe <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Functions
Date: Tue, 23 Nov 2004 00:59:11 -0800 (PST)
Hi wizs,
Anybody knows any fuction that can count occurence of a character in a 
string (not in a array).


-
A passion till tomorrow,
www.opeyemi.tk


-
Do you Yahoo!?
 Discover all that’s new in My Yahoo!
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] functions via event handlers

2004-09-07 Thread Neil Smith [MVP, Digital media]
Or you could use XMLHTTP on the browser side (supported by IE and Mozilla 
variants)

You'd send a GET request to the page, it would return - often - an XML 
record set, or you can return text, and indeed you can even query page 
status codes from the client side.

The point is, you no longer need to unload the current page to get 
information form the server.
Useful examples here : http://jibbering.com/2002/4/httprequest.html

Cheers - Neil
At 11:09 07/09/2004 +, you wrote:
Message-ID: <[EMAIL PROTECTED]>
Date: Mon, 6 Sep 2004 19:55:51 -0400
From: Joseph Crawford <[EMAIL PROTECTED]>
Reply-To: Joseph Crawford <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: Re: [PHP-DB] functions via event handlers
the closest you could come is to make javascript functions call php
pages basically redirects that would call the php functions.


CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] functions via event handlers

2004-09-06 Thread zareef ahmed
Hi, 

A small example


function call_me()
{
window.location="script.php";
}


 click me



If you are thinking about some live experience like
javascirpt with PHP you can go for flash and php.

In Flash Event calls php scripts and get the value
without reloading the flash movie.


Zareef Ahmed


--- Yemi Obembe <[EMAIL PROTECTED]> wrote:

> i'd just luv to ask if it is possibble to call a
> function in PHP by using event handlers (like
> onmouseover, onload) as done in javascript? if its
> possible, i'd appreciate someone to tutor me on it.
> 
> 
> 
> -
> 
> A passion till tomorrow,
> www.opeyemi.tk
> 
> 
> 
> 
>   
> -
> Do you Yahoo!?
> Win 1 of 4,000 free domain names from Yahoo! Enter
now.


=
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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



Re: [PHP-DB] functions via event handlers

2004-09-06 Thread Joseph Crawford
the closest you could come is to make javascript functions call php
pages basically redirects that would call the php functions.

-- 
Joseph Crawford Jr.
Codebowl Solutions
[EMAIL PROTECTED]
802-558-5247

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



Re: [PHP-DB] functions via event handlers

2004-09-06 Thread Philip Thompson
Yemi,
On Sep 6, 2004, at 7:14 AM, Yemi Obembe wrote:
i'd just luv to ask if it is possibble to call a function in PHP by 
using event handlers (like onmouseover, onload) as done in javascript? 
if its possible, i'd appreciate someone to tutor me on it.

As far as I know, this is not possible. Since PHP is server-side 
scripting (not client-side like JavaScript), all the code-processing is 
done before it ever reaches the client's computer. Because of this, you 
will never be able to use the code via event handlers.

If anyone knows something different, please let me and Yemi know.
~Philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Functions

2004-02-02 Thread Denzo
Easier is using their value, eg

$email = email(replacement(functions($_POST['email']))); // or _GET
$address = address(replacement(functions($_POST['email'])));

...


"Micah Stevens" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> Chis,
>
> I think this might do what you want:
>
> foreach ($_REQUEST as $key => $value) {
> switch ($key) {
> case "email":
> // do email stuff
> break;
> case "address":
> // do address stuff
> break;
> default:
> // in case it's something you haven't planned for..
> break;
> }
> }
>
>
>
>
> On Mon February 2 2004 4:36 pm, Chris Payne wrote:
> > Hi there everyone,
> >
> > I need to write a function (New to them but starting to get the hang of
it)
> > that will take the field from a form and then do operations on it (To
> > remove bad characters, any entered mysql commands etc ) now that's
not
> > a problem, what I want to do though is write a generic function that
will
> > handle ALL the fields in any form.
> >
> > For example, if I have 3 input boxes, name, address, email - I would
like
> > the function to recieve the data from each form string and do the
operation
> > and then send the info back keeping the same name and value that it
arrived
> > in.  I'm finding it hard to explain, but basically if a field is called
> > email and it's value is [EMAIL PROTECTED] then the function needs to be able to
> > automatically pickup that the incoming name is email and it's value it
> > [EMAIL PROTECTED] then process it and output it again, and i'm confused how to
do
> > it.
> >
> > I can do it if I specify the name of the form item coming in and going
out,
> > but since I want to make it generic I don't want a zillion different
> > possible form names in the function :-)
> >
> > Any help (If you can understand my rambling :-) would be greatly
> > appreciated.
> >
> > Regards
> >
> > Chris

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



Re: [PHP-DB] Functions

2004-02-02 Thread Jochem Maas
elaborating (?spelling) on Micahs loop:

funcs.php:

// using a variable variable name: $$glob now refers to $_REQUEST
// assuming no arguments were passed to the function.
// doing this allows sanitizing just $_POST, $_GET or $_COOKIE
// in case
foreach ($$glob as $key => $value) {
// sanitize all incomings
$$glob[$key] = $santizedValue;
}
}
function validate($value, $type)
{
$isValid = false;
switch ($type) {
case 'email':
// if email is OK do $isValid = true;
break;
case 'address':
// check address
break;
default:
   // the fallback plan.
   // e.g.
   if (!empty($value)) {
   $isValid = true;
   }
   break;
}
return $isValid;
}
?>
--endof funcs.php
test.php

require_once ('./funcs.php');

// clean and make safe our incoming values
sanitize('_POST');
$validationFields = array(
'myname'  => 'name',
'myemail' => 'email',
'myaddr'  => 'address',
);
// check to see if something was submitted
if(is_array($_POST) && count($_POST)) {
define('FORM_SUBMITTED', 1);
}
foreach($validationFields as $field => $type) {
// possibly we want to valid
if (defined('FORM_SUBMITTED')) {
// a form was posted...
if(!validate($_POST[ $field ], $type)) {
define('ERROR', 1);
break; // stop the loop
}
$$field = $_POST[ $field ];
} else {
$$field = '';
}   
}
if (defined('FORM_SUBMITTED')) {
if (!defined('ERROR')) {
// stick the data in a database or email them...
define('MSG', 'your data was excellently constructed!');
} else {
   // something bad happened
   define('MSG', 'something bad happened please check your data');
}
} else {
// something bad happened
define('MSG', 'welcome, please fill in this form');
}
?>


My Form


*name: 
*email: 
*address: 




--endof test.php

Micah Stevens wrote:

Chis,

I think this might do what you want:

foreach ($_REQUEST as $key => $value) {
	switch ($key) {
		case "email":
			// do email stuff
			break;
		case "address":
			// do address stuff
			break;
		default:
			// in case it's something you haven't planned for.. 
			break;
	}
}
	
		

On Mon February 2 2004 4:36 pm, Chris Payne wrote:

Hi there everyone,

I need to write a function (New to them but starting to get the hang of it)
that will take the field from a form and then do operations on it (To
remove bad characters, any entered mysql commands etc ) now that's not
a problem, what I want to do though is write a generic function that will
handle ALL the fields in any form.
For example, if I have 3 input boxes, name, address, email - I would like
the function to recieve the data from each form string and do the operation
and then send the info back keeping the same name and value that it arrived
in.  I'm finding it hard to explain, but basically if a field is called
email and it's value is [EMAIL PROTECTED] then the function needs to be able to
automatically pickup that the incoming name is email and it's value it
[EMAIL PROTECTED] then process it and output it again, and i'm confused how to do
it.
I can do it if I specify the name of the form item coming in and going out,
but since I want to make it generic I don't want a zillion different
possible form names in the function :-)
Any help (If you can understand my rambling :-) would be greatly
appreciated.
Regards

Chris


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


Re: [PHP-DB] Functions

2004-02-02 Thread Micah Stevens
Chis,

I think this might do what you want:

foreach ($_REQUEST as $key => $value) {
switch ($key) {
case "email":
// do email stuff
break;
case "address":
// do address stuff
break;
default:
// in case it's something you haven't planned for.. 
break;
}
}




On Mon February 2 2004 4:36 pm, Chris Payne wrote:
> Hi there everyone,
>
> I need to write a function (New to them but starting to get the hang of it)
> that will take the field from a form and then do operations on it (To
> remove bad characters, any entered mysql commands etc ) now that's not
> a problem, what I want to do though is write a generic function that will
> handle ALL the fields in any form.
>
> For example, if I have 3 input boxes, name, address, email - I would like
> the function to recieve the data from each form string and do the operation
> and then send the info back keeping the same name and value that it arrived
> in.  I'm finding it hard to explain, but basically if a field is called
> email and it's value is [EMAIL PROTECTED] then the function needs to be able to
> automatically pickup that the incoming name is email and it's value it
> [EMAIL PROTECTED] then process it and output it again, and i'm confused how to do
> it.
>
> I can do it if I specify the name of the form item coming in and going out,
> but since I want to make it generic I don't want a zillion different
> possible form names in the function :-)
>
> Any help (If you can understand my rambling :-) would be greatly
> appreciated.
>
> Regards
>
> Chris

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



RE: [PHP-DB] Functions - scope of returned result

2003-08-14 Thread Dillon, John
One more bite on this code.  

function queries(){
//code..
$piv_result=mysql_db_query($db, $query, $connection) or die ("Query9
failed: $query");
return $piv_result;
}

function print(){
global $piv_result;
$count_fields=mysql_num_fields($piv_result);  //ERROR: 
//code...
}

//MAIN 
queries();
print();

Should this work - $piv_result is being returned from one function and then
being used in another function.  Am I missing something?

John































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and 
Legal Statement at http://www.cantor.com/legal_information.html


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



Re: [PHP-DB] Functions - scope of returned result

2003-08-14 Thread John W. Holmes
Dillon, John wrote:
One more bite on this code.  

function queries(){
//code..
$piv_result=mysql_db_query($db, $query, $connection) or die ("Query9
failed: $query");
return $piv_result;
}
function print(){
	global $piv_result;
	$count_fields=mysql_num_fields($piv_result);  //ERROR: 
	//code...
}

//MAIN 
queries();
print();

Should this work - $piv_result is being returned from one function and then
being used in another function.  Am I missing something?
Yes, you're returning the result set, but you're not assigning it anywhere.

$rs = queries();
print($rs);
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


RE: [PHP-DB] Functions - scope of returned result

2003-08-14 Thread Dillon, John
To answer my own question again, I didn't assign the returned value from the
function call to a variable:

$piv_result=queries();

All OK.

-Original Message-
From: Dillon, John [mailto:[EMAIL PROTECTED]
Sent: 14 August 2003 17:54
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Functions - scope of returned result


One more bite on this code.  

function queries(){
//code..
$piv_result=mysql_db_query($db, $query, $connection) or die ("Query9
failed: $query");
return $piv_result;
}

function print(){
global $piv_result;
$count_fields=mysql_num_fields($piv_result);  //ERROR: 
//code...
}

//MAIN 
queries();
print();

Should this work - $piv_result is being returned from one function and then
being used in another function.  Am I missing something?

John































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any,
are confidential. If you are not the named recipient please notify the
sender and immediately delete it. You may not disseminate, distribute, or
forward this e-mail message or disclose its contents to anybody else.
Copyright and any other intellectual property rights in its contents are the
sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission.  If verification is required please request a hard-copy
version.
 Although we routinely screen for viruses, addressees should check this
e-mail and any attachments for viruses. We make no representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that to ensure regulatory compliance and for the protection of
our customers and business, we may monitor and read e-mails sent to and from
our server(s). 

For further important information, please read the  Important Legal
Information and Legal Statement at
http://www.cantor.com/legal_information.html


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

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



Re: [PHP-DB] functions IN the database.

2003-05-31 Thread Rolf Brusletto
*This message was transferred with a trial version of CommuniGate(tm) Pro*
the sites will reside on different boxes. Thus needing a way to share 
the functions. I'm trying to get away from having two sets of code that 
do exactly the same thing.

Becoming Digital wrote:

Forgive me if I'm overlooking something, but why not just use a class?

Edward Dudlik
Becoming Digital
www.becomingdigital.com
- Original Message - 
From: "Rolf Brusletto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, 30 May, 2003 17:10
Subject: [PHP-DB] functions IN the database.



Hey all -

I'm curious if anybody has ever setup the logic to put php functions 
into a database here is my thinkin on it, hopefully I can get some 
suggestions on the benefits, downsides, etc.

(in mysql)

CREATE TABLE `functions` (`functionId` INT (5)  UNSIGNED DEFAULT '0' NOT 
NULL AUTO_INCREMENT,
   `functionData` TEXT NOT 
NULL,
   `functionDesc` TEXT, 
PRIMARY KEY(`functionId`), UNIQUE(`functionId`));

INSERT INTO functions(functionData, functionDesc)
VALUES('function echoNumber($number)
   { echo $number; }',
'This function echos out a given $number');
(in php)
$sql = "SELECT functionData
   FROM functions";
$query = mysql_query($sql);
while($functionData = mysql_fetch_assoc($query)) {
   eval $functionData[functionData];
};
This in theory **should initiate the given functions listed in the 
functions table, has anybody used anything like this? I have a two sites 
that I NEED to use the same functions and this is the first thing that 
comes to mind, plus it would allow for  gui editing  of or creating 
functions via a secured webpage.

Thanks on advance!

Rolf Brusletto
http://www.phpexamples.net
 



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


Re: [PHP-DB] functions IN the database.

2003-05-31 Thread Becoming Digital
Forgive me if I'm overlooking something, but why not just use a class?

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message - 
From: "Rolf Brusletto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, 30 May, 2003 17:10
Subject: [PHP-DB] functions IN the database.


*This message was transferred with a trial version of CommuniGate(tm) Pro*
Hey all -

I'm curious if anybody has ever setup the logic to put php functions 
into a database here is my thinkin on it, hopefully I can get some 
suggestions on the benefits, downsides, etc.

(in mysql)

CREATE TABLE `functions` (`functionId` INT (5)  UNSIGNED DEFAULT '0' NOT 
NULL AUTO_INCREMENT,
`functionData` TEXT NOT 
NULL,
`functionDesc` TEXT, 
PRIMARY KEY(`functionId`), UNIQUE(`functionId`));

INSERT INTO functions(functionData, functionDesc)
VALUES('function echoNumber($number)
{ echo $number; }',
 'This function echos out a given $number');

(in php)
$sql = "SELECT functionData
FROM functions";
$query = mysql_query($sql);
while($functionData = mysql_fetch_assoc($query)) {
eval $functionData[functionData];
};

This in theory **should initiate the given functions listed in the 
functions table, has anybody used anything like this? I have a two sites 
that I NEED to use the same functions and this is the first thing that 
comes to mind, plus it would allow for  gui editing  of or creating 
functions via a secured webpage.

Thanks on advance!

Rolf Brusletto
http://www.phpexamples.net


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





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



Re: [PHP-DB] functions and using vars outside of them

2001-03-30 Thread Yasuo Ohgaki

I think it's time to read the manual.
http://jp.php.net/manual/en/langref.php
http://jp.php.net/manual/en/language.variables.scope.php
http://jp.php.net/manual/en/functions.php

--
Yasuo Ohgaki


""olinux"" <[EMAIL PROTECTED]> wrote in message
000f01c0b838$e332a3c0$6401a8c0@amdk7">news:000f01c0b838$e332a3c0$6401a8c0@amdk7...
I am wondering how to use a variable that is generated by a function ($query)
If you would please look at:
http://phpbuilder.net/columns/laflamme20001016.php3?page=5
for an example of what i am trying to do.

the function will generate the query... but how do i make use of this?
i see that i will need to call the function
skill_search($skills);

but this does not make the variables inside the function available.

thanks much,
olinux



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]