[PHP-DB] Re: Mapping objects to tables: the actual database object
Hello, On 03/03/2003 02:19 PM, Alexander Deruwe wrote: I'm investigating using PHP's OOP functionality instead of the traditional model to implement a project. I've been looking at information about mapping objects to tables, and have mostly found what In that case you may be interested in Metastorage. It is a persistence layer generator application that generates classes of objects that are mapped to database tables. It just takes a very simple description in a XML format of your classes with their variables, validation rules, relationships between objects and the types of functions that you need. Then it generates all for you including the code to install the database schema without any need for you to write a single line of code or SQL. It is Open Source and you may find more about it here: http://www.meta-language.net/news-2002-12-05-metastorage.html http://www.meta-language.net/news-2002-12-09-metastorage.html http://www.meta-language.net/metastorage.html When mapping objects to tables, how would one usually handle the actual database object? Suppose we have a class Database derived from The standard solution that Metastorage implements is to have a factory class that takes care of the creation of all objects, either retrieved from the database or created from scratch. The initialization of the factory class takes care of the database setup. Any database connection handles are passed to the new class objects when they are instantiated. -- Regards, Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Help with MySQL Logic
Thanks to everyone for your help. I was able to work out the logic last night based on your fine suggestions and all is well! Thanks again. Randy -Original Message- From: 1LT John W. Holmes [EMAIL PROTECTED] Sent: Monday, March 03, 2003 10:30 AM To: Rankin, Randy; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Help with MySQL Logic A client of mine, a rail car storage company, has asked that I create a PHP/MySQL application in which they will maintain and track rail cars. I am having a bit of trouble however working through one of thier requirements. They need to know in what position the rail car is on each track. For example, they might have a track called X which will hold 30 rail cars. They would enter the car information for 30 cars and associate each of them with track X. If one of the car owners decides to move car 3 out of storage, then the remaining 29 cars must be re-numbered ( ie; car 1 and 2 would remain and car 4-30 would become car 3-29 ). In the same manner, I need to be able to add a car to the track once an empty slot is available. For example, If the new car goes at the front of the track then it would become car 1 and the remaining cars, originally numbered 1-29 would become 2-30. Not sure if this helps or if you already realize this... Say you have a table that identifies the track_id and car_id. Now, you delete the car_id for car #3, like you've said. So, that row is deleted and you've got a hole now. You can run a query such as: UPDATE table SET car_id = car_id - 1 WHERE car_id BETWEEN 4 AND 30 AND track_id = XX to adjust all of the other car_id numbers. Now, say you want to add a new car to the beginning. UPDATE table SET car_id = car_id + 1 WHERE track_id = XX and then insert your new car at position #1. Throw in some checks to make sure you don't go over 30 cars and you should have it. You can get a count of how many cars are on a certain track with: SELECT COUNT(*) AS c FROM table WHERE track_id = XX Hope that helps. It sounds like a fun project. ---John Holmes...
[PHP-DB] date functions
I am looking for a way to take a date stored in a mysql database... and find out the date seven days later. how would i do this?! cheers, dave _ Chat online in real time with MSN Messenger http://messenger.msn.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date functions
I am looking for a way to take a date stored in a mysql database... and find out the date seven days later. how would i do this?! too easy... SELECT date_column + INTERVAL 7 DAY FROM your_table ... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date functions
Good stuff here. http://www.mysql.com/doc/en/Date_and_time_functions.html Check out the SELECT DATE_ADD section. That might be what you're looking for. HTH, Rich -Original Message- From: David Rice [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04, 2003 9:36 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] date functions I am looking for a way to take a date stored in a mysql database... and find out the date seven days later. how would i do this?! cheers, dave _ Chat online in real time with MSN Messenger http://messenger.msn.co.uk -- 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
[PHP-DB] date functions
I want to use it in this function that i am creating (it's for a resteraunt automated tips system, to work out how much tips each staff member is entitled to. function tips($weekstart){ /* JUST BELOW HERE IS WHERE I NEED TO GET THE DATE OF 6 DAYS AFTER THE SPECIFIED DATE OF THE START OF THE WEEK */ $weekend = date($weekstart +6); $query = SELECT * FROM Rota WHERE date = $weekstart AND date = $weekend ORDER BY staffid; etc... _ Surf together with new Shared Browsing http://join.msn.com/?page=features/browsepgmarket=en-gbXAPID=74DI=1059 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date functions
I want to use it in this function that i am creating (it's for a resteraunt automated tips system, to work out how much tips each staff member is entitled to. function tips($weekstart){ /* JUST BELOW HERE IS WHERE I NEED TO GET THE DATE OF 6 DAYS AFTER THE SPECIFIED DATE OF THE START OF THE WEEK */ $weekend = date($weekstart +6); $query = SELECT * FROM Rota WHERE date = $weekstart AND date = $weekend ORDER BY staffid; etc... What format is $weekstart in? Maybe you said already, I can't remember. You could try $weekend = strtotime($weekstart . ' +6 days'); Since I think your 'date' column is a TIMESTAMP, you'll need to format $weekstart and $weekend as MMDD in order to get what you have above to work. Maybe try this: function tips($weekstart){ $start = date('Ymd',strtotime($weekstart)); $query = SELECT * FROM Rota WHERE date = $start and date = ($start + INTERVAL 6 DAY) ORDER BY staffid; etc... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Update MD5 field
Daniela, Why do you want to keep a calculated field inside your database? -- Beverly Steiner [EMAIL PROTECTED] -Original Message- From: Dani Matielo [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 10:18 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Update MD5 field Hello, everybody my problem is the following: I just imported a csv file to a MySQL database that contains name and email fields. It has about 9k lines on it and I need a new field that orinally didn't exist called code thats suposed to be MD5(name.email) I know how to do this for new data, but I don't know how to update all the old ones I already have there. Thank you in advance, Daniela -- 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
[PHP-DB] preg_match_all
Hi All, Well i need a little help as allways. Lets say that i have this output: -- brfield1: value1 brfield2: value2 brsomefield: somevalue -- I want the value in between br and this : and the value between : and \n So that i could do whis: print($field1br); print($field2br); print($somefield); Souch that this would give this output: value1 value2 Somevalue Thanks a lot Lars Rasmussen. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Serialize...Unserialize
I have an array of values I want to store in a MySQL db in a column called readBy of type TEXT. I want to take that array and serialize it then insert it into the db. No big deal. When I query the db and get the value from the readBy column, I know I have to unserialize it. Again, no big deal. My question about all of this is once I unserialize the data from the column, can I immediately use the array_push() function to append additional data to the unserialized data? Will the unserialized data immediately be recognized/treated as an array? Also, is the TEXT dolumn type an appropriate column type to store serialized data or is there another column type that should be used? Lots of questions I know. Just wanted to make sure that it's really as easy as unserialize() then array_push() with nothing else required. Thanks in advance. Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mysql compress text field?
Hello to all, I have a new project where i need show pages of report on demmand. That reports are created in the batch process, and the whole file size is about 5 Gb. (thats includes all the reports in a month, I need save about 12 month). I think in two alternatives : 1. I save the links in a mysql database, but the files are compressed (in zip format) in several directories, one directorie by day, so when the user request one report, I query the database, go to the path, decompress the file and return to the user. 2. I save the reports on the mysql database, so when the user request one report, I query the database and return the report. But if MySql don't compress the text field, that way is not practicable (HDD is limited). Any ideas or suggestions? Saludos, Patricio Vera S. ___ Yahoo! Móviles Personaliza tu móvil con tu logo y melodía favorito en http://moviles.yahoo.es -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Serialize...Unserialize
Hutchins, Richard wrote: I have an array of values I want to store in a MySQL db in a column called readBy of type TEXT. I want to take that array and serialize it then insert it into the db. No big deal. When I query the db and get the value from the readBy column, I know I have to unserialize it. Again, no big deal. My question about all of this is once I unserialize the data from the column, can I immediately use the array_push() function to append additional data to the unserialized data? I would imagine because the output of unserialize() is of the array type. Unless, there was an error unserializing it. Will the unserialized data immediately be recognized/treated as an array? Yes. Also, is the TEXT dolumn type an appropriate column type to store serialized data or is there another column type that should be used? If you can guarantee that the data doesn't go above 256 characters, then a varchar column can be used. But serialized data can get pretty big, so anticipate for it, by using text columns. -- Gerard Samuel http://www.trini0.org:81/ http://test1.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mysql compress text field?
I have a new project where i need show pages of report on demmand. That reports are created in the batch process, and the whole file size is about 5 Gb. (thats includes all the reports in a month, I need save about 12 month). I think in two alternatives : 1. I save the links in a mysql database, but the files are compressed (in zip format) in several directories, one directorie by day, so when the user request one report, I query the database, go to the path, decompress the file and return to the user. Use this method. 2. I save the reports on the mysql database, so when the user request one report, I query the database and return the report. But if MySql don't compress the text field, that way is not practicable (HDD is limited). You'd have to zip the files, then read the data to insert into the table. Then, to retrieve, you'd have to select the data out, write it to a file and unzip it before you sent it to the user. (According to your remarks) Sounds like a lot of wasted time to me. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date functions (generates parse error)
Here is the whole code of my function Whenever i run it, it say's there is a parse error on line 6, can't see what is the problem the format of $weekstart (as it is stored in the Database) is -MM-DD = ? function tips($weekstart){ $start = date('Ymd',strtotime($weekstart)); $query = SELECT * FROM Rota WHERE date = $start and date = ($start + INTERVAL 6 DAY) ORDER BY staffid; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ if ( isset ( $tips ) ){ if (isset ( $tips[$row[staffid]] ) ){ $hours = $row[finish] - $row[start]; $tips[$row[staffid]] = $tips[$row[staffid]] + $hours; } else{ $tips[$row[staffid]] = $row[finish] - $row[start]; } } else{ $tips = array('$row[staffid]' =( $row[finish] - $row[start] ) ); } } return $tips; } _ Stay in touch with absent friends - get MSN Messenger http://messenger.msn.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date functions (generates parse error)
Here is the whole code of my function Whenever i run it, it say's there is a parse error on line 6, can't see what is the problem the format of $weekstart (as it is stored in the Database) is -MM-DD = ? function tips($weekstart){ $start = date('Ymd',strtotime($weekstart)); $query = SELECT * FROM Rota WHERE date = $start and date = ($start + INTERVAL 6 DAY) ORDER BY staffid; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ if ( isset ( $tips ) ){ if (isset ( $tips[$row[staffid]] ) ){ $hours = $row[finish] - $row[start]; $tips[$row[staffid]] = $tips[$row[staffid]] + $hours; } else{ $tips[$row[staffid]] = $row[finish] - $row[start]; } } else{ $tips = array('$row[staffid]' =( $row[finish] - $row[start] ) ); } } return $tips; } I cut and pasted your exact code here and didn't get a parse error. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Serialize...Unserialize
Thanks for the feedback, Gerard. One thing I've learned in this experiment is that once the data is serialized and put into the readBy (TEXT) column, I can't really do any queries that do comparisons on the data stored in that column because of the serialization markup. Unfortunately, this is a requirement in this particular case. I can hear the collective Duh! from everybody out there now ;^) What can I say, I had to learn the hard way. Unless I'm wrong, it looks as if I need to go back to doing implode()/explode() on this data in order to preserve the comparisons I need to do inside other queries. Which I don't mind, I was just hoping serialize()/unserialize() would make life easier. Lesson learned. Thanks, Rich -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04, 2003 1:39 PM To: Hutchins, Richard Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Serialize...Unserialize Hutchins, Richard wrote: I have an array of values I want to store in a MySQL db in a column called readBy of type TEXT. I want to take that array and serialize it then insert it into the db. No big deal. When I query the db and get the value from the readBy column, I know I have to unserialize it. Again, no big deal. My question about all of this is once I unserialize the data from the column, can I immediately use the array_push() function to append additional data to the unserialized data? I would imagine because the output of unserialize() is of the array type. Unless, there was an error unserializing it. Will the unserialized data immediately be recognized/treated as an array? Yes. Also, is the TEXT dolumn type an appropriate column type to store serialized data or is there another column type that should be used? If you can guarantee that the data doesn't go above 256 characters, then a varchar column can be used. But serialized data can get pretty big, so anticipate for it, by using text columns. -- Gerard Samuel http://www.trini0.org:81/ http://test1.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP and MS SQL Server 7.0
I would like to use PHP to open a connection to a MS SQL server, query the database, and then use the query results to generate dynamic content for a mass HTML e-mail campaign. Is it possible to execute PHP scripts in an HTML file or must the file have a .php extension? I'm limited by the software my employer uses (UnityMail, maybe someone's familiar with it?) which requires that the HTML code for the message body be pasted into a client-side form that the software then uses to generate the message and deliver it to the list of recipients. Any help is greatly appreciated! Cheers, Michael Morrison Valparaiso University http://www.therainforestsite.com/ http://www.thehungersite.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP and MS SQL Server 7.0
Hello, On 03/04/2003 06:22 PM, Michael Morrison wrote: I would like to use PHP to open a connection to a MS SQL server, query the database, and then use the query results to generate dynamic content for a mass HTML e-mail campaign. Is it possible to execute PHP scripts in an HTML file or must the file have a .php extension? I'm limited by the software my employer uses (UnityMail, maybe someone's familiar with it?) which requires that the HTML code for the message body be pasted into a client-side form that the software then uses to generate the message and deliver it to the list of recipients. Any help is greatly appreciated! You can do it all in PHP. Try for instance this class for composing and sending e-mail messages that comes with an example for sending personalized bulk mail. http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Problem with php and mysql
Hi everyone, One of our customers has written a php application that we are hosting. Basically, there is a province/state table which populates a combo box. When the form containing this combo box is submitted, the information is added into the database. The problem is that when nothing is selected from the combo box, it adds a number which seems to be random in the database, rather than the province/state ID which it references from the province table. Obviously there are many methods of avoiding this such as javascript to make sure something is selected, or even giving the combo box a default value, but I was wondering if anyone knew why the database itself isn't catching the error (foreign key violation) and accepting the data. Any ideas? Thanks in advance for any help, Kevin --- Kevin Demers Technical/Customer Support Internet Access - WORLDWIDE 3 East Main Street Welland, ON Canada L3B 3W4 (905) 714-1400 (800) 560-4560 [EMAIL PROTECTED] www.iaw.on.ca -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php and local printing
It dopesn't seem like you got an answer to this. To print locally, you'll need to use Jscript of something similar on the local end. I've only seen this work in IE, but I haven't looked into it too deeply. To print to the server, you'll probably need to shell out to the OS. HTH or at least starts a discussion... --- Rajesh Fowkar [EMAIL PROTECTED] wrote: Hello, What is the best way to print on a locally connected printer from php ? For printing we want to give the user three options : 1. Screen 2. Local Printer 3. Server Printer What you guys are using for printing on locally connected printer from php. Thanks in advance. Peace -- Rajesh : [ GNU/Linux One Stanza Tip (LOST) ]### Sub : kill-proc (killing user process by an user)LOST #285 #!/bin/sh ps -aef | grep $USER echo -en Process-No to kill : ; read P_ID kill $P_ID [EMAIL PROTECTED] : -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a right unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php and local printing
On Tue, Mar 04, 2003 at 06:45:54AM -0800, Mark wrote: It dopesn't seem like you got an answer to this. Spot on. Yours is the first reply. To print locally, you'll need to use Jscript of something similar on the local end. I've only seen this work in IE, but I haven't looked into it too deeply. To print to the server, you'll probably need to shell out to the OS. Using javascript window.print() I get the print dialogue box. But what I needed was I have got a text file which on server I can print using lp filename. Similar thing but without any print dialogue box at the client end. HTH or at least starts a discussion... Hope so. Thank you for the reply. Peace -- Rajesh : [ GNU/Linux One Stanza Tip (LOST) ]### Sub : Linux Commands (#4)LOST #056 For a newbie introduction to Linux commands and shotcuts visit URL: http://sunsite.dk/linux-newbie/Linux_commands.htm [EMAIL PROTECTED]## : -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP on Mandrake
Hi there everyone, Just installed Mandrake Linux 9.1 with Apache 2.0 which is excellent. However, PHP isn't configured and from what I can tell the version it installed (Mandrake) is the CGI version when I got the info from the command line. How can I configure Apache 2.0 to use the CGI version of PHP? All the bits i've found online is for mod_php or something? Windows is easier and setup fine but I decided it's time to really get my hands dirty (God help me :-) Thanks everyone. Chris
[PHP-DB] Re: Help with a query
i am not testing this... just writing it here. and it is 2am ! SELECT shopping_cart.item_id, shopping_cart.subtotal, shopping_cart.quantity FROM shopping_cart, orders WHERE shopping_cart.order_id = orders.order_id AND orders.session_id = session_id() AND orders.customer_id = '$customer_id' i guess u could give it a try. just a simple 2 table join. i may not have the fields and order in place but try it Joel Colombo Jonathan Villa [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I can't figure this query out. I want to pull data from 2 tables but using a primary key from one. Here is what I think it should look like. SELECT item_id, subtotal, quantity from shopping_cart WHERE order_id = (SELECT order_id FROM orders WHERE session_id = session_id()) AND customer_id = $customer_id; -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php