How About Auto Loading Data Models
Consider you have a model like this
class samplemodel
{
public method setName(){/*set the name*}
public method setEmail(){/*set the email*}
}
Models are usually relevant to database tables. So if you have tables
with 10-12+ fields you may define accessor methods for all these
fields in your model. Now when loading data manually in the model
after submitting an HTML form you need to call them like this
$model = new samplemodel();
$model->setName("some name");
$model->setEmail("some email");
..........................
For models with few accessor methods it may be easy to type manually
all these data. But for 10-20-30 its totally ridiculous.
Thats why I designed this small Automatic Data Loader class which
takes a model as first argument and and data array as second argument
and then loads data from that array to that model. How is it looking?
<?
class dataloader
{
public static function load($module, $array)
{
$array = inputfilter::filter($array);
foreach ($array as $key=>$val)
{
if (is_callable(array($module,"get{$key}"),$callable))
{
echo "$key<br>";
call_user_func(array(&$module,"set{$key}"),$val);
}
}
}
}
?>
Now if you have two input object named "email" and "name" for example
in yoru html form and you call this loader as shown below, it will
load all the data from $_POST to the model automatically.
$model = new samplemodel();
dataloader::load($model, $_POST);
as the model is accessed with BY_REFERENCE style, so it will fetch
$model->setName() and $model->setEmail with appropriate $_POST data
and your model will be loaded automatically.
This comes really handy when you have to load models with many
accessor methods. I developed this object while working for Bangla
Chat Engine last night and Ha Ha HA, it really saves my time.
Caution: Using raw user submitted data from $_POST or $_GET is not
secured. You should filter them first.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
User Management Models
does anyone know where to find information about different user management models. What sort of model to use for what kind of complexity. how to realise the different models and so on...
Loading Data In Hebrew From DB
wile trying to load hebrew from DB the result I get is :? I have already checked the connection but the problem is not there. I ges I need to set font in php using some ISO in order to get normal output the big problem is that I dont know HOW!
Which Functions To Use For Data Loading
I need to make a script where users will upload a comma seperated values (CSV) text file which will be inserted in a table. The user must be able to review and approve the extracted data from the CSV file before it is inserted in the table. There could be up to 1000 rows of data. What PHP functions must I utilize to complete this script?
Loading All The Data Of A Page Into A Variable.
I was wondering how you would go about emulating header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=' . 'test' . '.csv'); but instead of getting a file...I would like to load all the data into a variable. Is this possible?
Saving/Loading Data In Drop-down List
I have a drop-down list with set values. When there is a corresponding value in my database when the page loads I want the drop-down list to pick the appropriate value from the list. Instead it always defaults to the first value. Can anyone give me an example of how to do this? Also, one time after adding a variable to a classes file this symbol:  started showing up on all of my pages. Has anyone seen this before? I can't find any information on the web about it.
Inserting Data Into A Table With Auto Increment In One Field
i have a table with several fileds in and with the first one being an auto increment field. I want to know what my SQL query should be when inserting data. Here's my current one: Code: $SQL = mysql_query("INSERT INTO $usertable2 VALUES('$subject', '$newstext', '$date', '$usrname')"; The auto increment field is the first in the table and is called 'postid'. can someone give me the correct query please? also do i need the first entry in the table to be a blank one with just the postid entered at one?
Loading A Class From A File - Dynamic Class Loading
I want to load a class from a file, and I have tried to do so with little success. Here's a sample of my code: include("CMWebServiceImpl.class.php"); $fs = new filesystem(); $data = $fs->readFile("/home/keeb/test.res", "r"); $x = new $data("http://192.168.2.37/services/Router?wsdl"); This returns Fatal error: Class 'CMWebServiceImpl ' not found in /home/keeb/projects/php/cmsService/classes/classFromFile.php on line 10 However, this is not the case, since I can call with success: $y = new CMWebServiceImpl("http://192.168.2.37/services/Router?wsdl"); Anyone do anything like this before?
Bypassing "submit" Or Auto Submit With Forms Data
In a regular HTML screen where you have inputs within a FORM, you usually have a SUBMIT input tag to submit the form data to the action'ed item in the form tag. In alot of sites, I see that you can enter a field, then to its immediate right, is a GO button to submit the choice. Has anyone had experience with this, and if so, how would you code that in PHP? I have also seen where you can choose something from a dialog box, and as soon as its chosen, the form data is submitted. Is that possible in PHP also?
Loading Bar
I've been wondering if I can have a loading bar while my script is loading in the background. So it doesnt look like my site is slow. Kinda like the new beta hotmail and yahoo. I thought of a simple idea. But dont think it will work. Just send the output of the loading bar and then access the script. Then finish the output. Just in one php page.
Mediaplayer Loading
Hii made a video clip site on which videos play in windows media playerclient wants that when the video is loading a small clip or text should show which should say Video loading......plz waitis this possible to do can anyone tell how to do this.
Loading A Database
Hi i have a saved database, i would like to load back how can i do this using phpmyadmin?.
Slow Loading
I recently moved to a new server. I've noticed that index.php (first page anyone sees) is extremely slow to load. On the old server it loaded fast. The servers have the same specs. What could the issue be?
Page Loading?
At last page of my prepaid system i want to show the information of the user means display congratulation,the username and password etc. which he/she choosen before. And at the last line i use a perl script which disconnect the user(Dial up) using killuser. But the whole code is execute at a time for that perl code is execute before the php file load. As a result the user never seen the username and password because the dialup line is disconnect before the information page is load. Some of my code is : echo "Thank you for chosen the $username"; echo $username; echo $password; And the last of my code is : $kuser = "/usr/bin/killuser.pl $prepaid_serial_number"; $run=exec($kuser);
Loading Oo Php Libraries
how do i include a php file that contains just class definitions as when i use the normal include("classfile.php"); it displays all the code in the client, anyone know how this is done,, i really need it,
Download Instead Of Loading
I currently keep all my intended downloadable files in a folder. I just hyperlink and list them all out. For all the other file formats when i just click on the links i will be prompt to save them. But .php extension files just tries to load up....why?
Loading PHP Into Form
I want to pull some data from my DB and display it into a HTML FORM textarea field. This can be done with a JavaScript command which set's the field equal to true. This can be done with something like: document.rsform.Paper.value = <? echo("$var")?>; All good except when you have a field with multiple values which looks like this: text1 text2 JS spits out an error message. Any suggestions about how I could get this text field, containing end of lines, in my DB into my HTML form textarea field would be appreciated.
Loading Screen
I've seen a really cool effect which i would like to use on an intranet site. Am referring to the 'LOADING..' animation you see when switching pages. I've seen it somewhere on a website that was using php (cant remember the url). I've tried googling but came up with nothing - so does anyone know what function of php allows to display a little animation while a sql query is being run ?
Loading Url From Sql Table.
A flash website in which a person chooses to display products by category (from a pull down menu). Once a pull down menu is choosen a php script is loaded. Here is where the problem is !!!! What i want is that the php to go to that specific category table (which has id,name and url)and load the url from the table. If the url loading is successful then the user will get a pop up window with the "first product" which is id=1. Each time the user presses next the other id's thus urls are loaded till there are no more products to display.
Mediaplayer Loading
Client wants that when the video is loading a small clip or text should show which should say Video loading......plz wait is this possible to do can anyone tell how to do this ....
Loading External Dll
I extract the php-4.0.4pl1-Win32 into my local PC C:php directory. I follow all the instruction in install file and find that the php script work. Then i go to uncomment the entension for external dll that needed in win.ini and also change the path extension_dir=C:phpextensions. the problem is each time i load the php script, it will prompt out the error message "unable to load dynamic library "c:extensionsphp_oracle.dll". can some one help me to resolve this problem?
Json.so Not Loading?
I've installed json.so using pecl and its in the right place, it is specified in the php.ini file, however when I run a script that calls either of the two json commands I get the "Fatal error: Call to undefined function json_encode()" error. I've restarted apache, and even restarted the entire machine that its running on. Permissions on the json.so file are the same as other libraries that are working.
Loading Message.
I was wondering if there was a way to display a message while a script loads. I have a safety deposit box script, and if people have alot of items, it takes a while to load the script. So some people are sitting at a dead page for a couple seconds. So to inform them that their page is being processed, I would like to display a message while the script loads up everything from the database. I am not aware of a function that does this, but maybe someone else does. If someone could point me in the right direction that would be great.
Loading Php_ldap.dll On Windows NT4
Okay all of my other extensions load correctly but when I try to load the php_ldap.dll, I get the following error: Quote: Unable to load dynamic library 'd:/php/extensions/php_ldap.dll' - The specified module could not be found. Do I need some sort of LDAP library installed on my machine...all I want to do is connect to an external ldap server.
Loading Another Page Within Script
Quick Question for a newbie, I would like to know how i can get php to point another page, so that in the middle of a script eg. www.somedomain.com/firstscript.php the php script can make the web browser load the next page eg.
Some Images Not Loading After Refresh?
I'm using a meta refresh tag to reload a page after adding data to database. I have 3 button images on this page. The problem is that sometimes upon refreshing one or two images do not load. It's sporatic, meaning if the page reloads 5 times, the first 4 times all the buttons will load fine and on the 5th reload one of the buttons decides not to reload. Any Idea why?
Loading An Array Into A Form
I want to load an array of information into a form. It works okay with JS, providing there is only one field of data in the array as soon as there are two I get the error "unterminated string constant".
Exit() And Page Loading
I am using exit() at the end of an "if" statement that identifies if a variable has or has not been submitted to the page. The problem is that if the variable does "not" exist the exit() stops the script at that point and the rest of the page does not load. If I take out the exit() then the php script continues to run but when the script reaches the point that it need the variable it spit out an error and once again the remainder of the html page does not run. Any ideas on how to fix this problem?
Loading... Please Wait Script?
What's the best way to handle a "Loading, please wait" type of page? We have a link that generates a large file and would like to tell the user what is going on. Maybe have it up there for 20-30 seconds or so. Is it just a matter of a pop-up while the main window loads the file? Is there a way to detect if the file is loaded then close the pop-up?
Problems Loading Libgd2
I've installed a gd2 lib (previous 1.8.4) on my red hat 8 machine with php 4.2.2 (rpm binary package as apache module). As libphp4 loads libgd.so.1.8.4 as default, how can I compile php to permit libphp4 to load libgd2?
Php_mysql.dll Extension Not Loading
I've enabled php_gd2.dll and php_mbstring.dll in the php.ini file and they're loading ok but the php_mysql.dll is not getting loaded. Apache's error.log reports: PHP Warning: PHP Startup: Unable to load dynamic library 'c:/program files/php/ext/php_mysql.dll' - The specified module could not be found. in Unknown on line 0 What puzzles me is that the MySQL server works ok, PHP works ok, several extensions work ok but php_mysql.dll cannot be found although it is in the extension directory.
Print Out Before Loading Another Webpage
Is there a way to printout some string before loading a new page. I use sleep after I print something out and then used a header to direct the browser to another page. For example: echo "Foo"; sleep(10); header("Location: ./foo.php"); So far, php did not print out anything and the browser goes directly to foo.php
Loading Variables To Get Jpg (image)
I am trying to set a date loaded from a my sql database as a session variable then use that variable to check against the current date to determind what image should be displayed on the page. I am using this script to set the variable <?php session_start(); session_register("fresh_01_up"); $fresh_01_up = $fresher01->Fields('fresher_up');?> Then i am using this to determind which image to load. <?php if ($fresh_01_up == date("Y-m-d")){ echo "<img src=/"tint_fresher_01.jpg/">";} else{ echo "<img src=/"fresher_01.jpg/">";}?> Unfrortuantley i keep getting parse errors on the 3rd line of the second script, i really can't see what the problem is, any ideas??
Mssql Module Not Loading
I have PHP 5.2.1 installed on IIS, WinXP Pro. The MSSQL module is not loading, or any other module that needs to be loaded manually. PHP in general works, I am able to run phpinfo(). In the php.ini file I specify the extension directory correctly extension_dir = c:phpext I removed the comment ";" from the beginning of the mssql extension line. Here is the strange thing, when I run phpinfo() it shows the extension_dir as C:php5 and it says the php.ini configuration path is c:windows, but there is no php.ini file in that directory.
Loading Csv File Into Mysql
I have discovered the beauties of the 'LOAD DATA INFILE' mysql command. However, I was wondering if someone could help me manipulate my command to accommodate for the 3 potential types of line endings -- ' ', ' ', and ' ' (or whatever is the default line ending on Windows systems). What I have so far is ... $query = "LOAD DATA INFILE "$src_file_path" REPLACE INTO TABLE HB_USPS_ZIP_CODES FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY ' '"; $dbh = mysql_query($query);
PHP 5 Extension Not Loading Properly.
I've got an extension that I coded as a DLL in Windows and can use the dl() function to load it with no problem. This makes my test functions available and everything works fine. I'd like to keep the DLL resident in memory and tried adding it to PHP.INI (and don't call dl() ), but the functions in my DLL aren't available to my PHP script. Is there something special I need to do? I don't want to recompile PHP with my code - I can't think of a worse way to spend the holiday weekend...
Prevent Loading Of Php Pages
I have a website consisting of php segments. Example page1.html calls in code from seg1.php and seg2.php If the user goes directly to www.mydomain.com/seg1.php they see everything visible to a browser on that page. Can I prevent users from loading individual php segments. The only time that seg1.php should be visible is in its original context on page1.html
Php Array Loading/retrieval ?
I'm digging myself a hole on this one so I thought it has come to the time when I must ask those who know. I have what should be a simple question for loading, accessing and retrieving values stored in a simple one-dimensional array. I am simply trying to determine the occurrence of numbers as they appear in a file. For example lets assume the lowest allowed value is (00) and the highest allowed value is (35) and the numbers could occur from zero to n times over the course of a period of time. The problem I am having is referencing the array elements as strings but it appears in reality its being references as a vector/index. I am creating the array with: $array_name=array(); then I am incrementing the count with: $X=the number I've parsed from the file; $array_name[$X]++; then at the end I am using a for loop to print it out: for($X=0;$X<=highest_allowed_value;$X++) { print $X, $array_name[$X]; } Of course, my field names are different and I think that the references to the $X in the brackets are being interpreted as numeric vectors but when I try to convert them to a string and use them it also fails. Can someone PLEASE set me straight on the proper technique to accomplish this? As much as I've used PHP over the years I usually have no issues with arrays except when I need strict numeric indexing. Go figure.
Loading A Php File In A Template
I would like to include a file that is generated by an php script. I am currently loading a html template: my $template = HTML::Template->new(filename => "template/mainpage.template", die_on_bad_params => 0); And in mainpage.template I have the line: .. .. .. <TMPL_INCLUDE NAME="myfile.html"> .. .. .. Instead of myfile.html loading I would like to load the html generated by myfile.php. Is there a way to do this?
Re Prevent Loading Of Php Pages
a while back, on website a security issue that comes up often. Gary Jones was asking how to keep users from directly accessing php pages, out of sequence. Jerry posed a directory management solution. No one seems to have mentioned an alternative. Maybe there is a reason? We took a different approach, noting that the only way we wanted a user to enter some phps would be through a predefined series of steps like that posed by Gary Jones. Header information (http_referer, or maybe another) is a path check. If a client request hits, say, step_4-something.php without going through steps 1, 2, & 3, the php takes suitable action, maybe posting an error message.
Loading Websites In Parallel
I have a difficult problem: An array contains several different URLs. I want to load these websites in parallel by using a HTTP-Request. How can I do this in PHP? Up to now I did this with an external Python script because Python offers process control functions. But in PHP only exist restricted possibilities for using threads / processes. But now I want to do this in PHP, i.e. I wan to load some Website in parallel in PHP - but I haven't found any possibility to do this in PHP. there are some Python scripts that load some websites in parallel without using processes or threads. I think (I'm not sure) they do this with sockets (PHP: streams?) which are controlled ongoing (PHP: loops?). How can I load some websites in parallel in PHP by using a HTTP-Request? (This might be done in a way similar to twistedmatrix, but I didn't succeed...)
Page Loading Problem
the below code is kinda working but its only loading part of the page, when I do a page refresh the rest of the page loads. the part of the page that is not loading correctly is the bottom 1/2 which displays images. Code:
Slow Loading Page
Have a website using a mysql database with php pages created to add to fields in the database. One of the pages has recently started to take minutes to load and when I go to 'save' changed info to be loaded in to the database, it takes up to 20 minutes ... times out and often does not save the changes.
Error Loading MySQL
I've done a fresh install of xampp 1.6.3 and when I click on "phpMyAdmin" on the left side, I get the following error: Cannot load mysql extension. Please check your PHP configuration. - Documentation I looked in PHP.INI and verified the extension was in fact being loaded (and verified the file was found in the extension directory). Any ideas what this might be, or other investigative steps I can persue?
Dynamic Class Loading
Is there a way to load a class based on a string (other than with eval)? e.g. $someClassName = 'className'; $obj = new $className();
Loading Image Crop
All the scripts and functions that I have researched and looked into require you to specify a destination image, I would like to use the source image and crop the output for just the loading page and would like to avoid having 2 images one full and one cropped since both images will be used, and space will be a big issue which is why I'm trying to avoid a 2nd image. Now since I don't have code to trouble-shoot I'm not looking for code to be placed here, what I would like is a point to the right direction that way should I need it I can reply with code to trouble-shoot.
Loading Information From Database
I need to load information from a database to a form to be modified. Below is the code to load the field title into a text field. Not working...... what is wrong with the code below? echo "Title:<input type="text" name="title" size="50" value=$row['title']"><br>";
|