[PHP] Re: using mysql_close() = best practice?
On 24/10/2009 7:36 PM, Kim Madsen wrote: Hi PHP closes an open db connection when the script is done. I've read somewhere that in PHP6 this behaviour will dissapear, is this true? In that case using mysql_close() would definetly be best practice in all current scripts, to make it portable. A nice solution would probably be adding a end_mysql() or page_end() to all pages and put whatever is needed into that function (mysql_close, mysql_free_result, etc) I can't say with any certainty whether that is true or not - but it certainly seems like it is false. Non-persistent connections are destroyed automatically by the garbage collector when no more references are detected. See http://au2.php.net/manual/en/language.types.resource.php#language.types.resource.self-destruct That said, I believe it to be good practice to close any opened database connection. All my database methods are wrapped in a class, however, so I do this in the destructor. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange behaviour with uploaded files .. XAMPP on Windows
On Tue, 2009-10-27 at 11:31 +1000, Angus Mann wrote: Hi all. I'm not sure if this is really a PHP question or specific to XAMPP, or windows in general... I have XAMPP including PHP 4.29 running on a Vista machine. When I use a form to upload a file, using $_FILES['uploadedfile']['name'] and move_uploaded-file($_FILES['uploadedfile']['name'], $targetpath) strange effects happen. The file is uploaded to the target directory just as it should. But when I access this directory as a network share on a different machine, the file is not visible. When I go to delete the file, or the entire uploads folder, the file is not deleted, nor the folder. If the folder contains anything I put there manually (ie. not uploaded as above) that is deleted, but the uploaded content remains. This reminds me a bit of symbolic links behaviour but I'm really stumped if that's the case. Any ideas? Also, try not to hijack someone elses thread. When making a new thread, you shouldn't just use a reply to all from another message but create a whole new email, because a lot of us use email clients that are thread aware, and group message by thread, which is not the same as by subject! Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Tue, 2009-10-27 at 10:25 +, MEM wrote: I think the term drop-menu is bad in this case, as essentially what you are saying is: 1) user is presented with the basic navigation menu 2) user clicks an item and page navigates somewhere else 3) because of the item user clicked in 2) display some extra menu items Exactly. That's not a menu, it's just a navigation bar that changes slightly depending on where you are in the site... Ok... So the focus should not be on the click events, but on the URL changes. Since it will be based on URL changes and not, on click/hover events, I can rely this navigation system entirely on php. Right? If this is correct, the only think I need then, is to create a condition, to show/hide ul/li items based on: a) the url changes. OR b) the existence or non-existence of child array elements that needs to be verified each time the user navigates to a page. Is this correct? Thanks again, Márcio That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, so you only need to retrieve those that the user is interested in, which is shown by what they click on. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] What is the best practice for adding persistence to an MVC model?
Hi Eric, IMO, controllers shouldnt be responsible for interacting models and datastoreres. Controllers might only change the datastore class of a model. You may use your models in lots of controller functions. Defining datastore in all controllers seems not a good practice. (too much unneccessary codes written) A simple example //controller Public function doItController() { $user = new user(); // $user-setDataStorer(new anotherDataStorer()); // this is optional if you want to change models datastorer $user-loadUserFromId(1); } // model Class user { Protected $_dataStorer = null; Public function loadUserFromId($id = 0) { // codes codes codes $result = $this-getDataStorer()-query(select .); // codes codes codes } // codes codes codes Public function getDataStorer() { if(null == $this-_dataStorer) $this-_dataStorer = new myVeryBestDataStorer(); return $this-_dataStorer; } Public function setDataStorer($newStorer) { $this-_dataStorer = $newStorer; } } Hope it will be usefull and understandable -Original Message- From: Eric Bauman [mailto:baum...@livejournal.dk] Sent: Tuesday, October 27, 2009 8:27 AM To: php-general@lists.php.net Subject: [PHP] What is the best practice for adding persistence to an MVC model? I'm in the process of implementing an ultra-light MVC framework in PHP. It seems to be a common opinion that the loading of data from a database, file etc. should be independent of the Model, and I agree. What I'm unsure of is the best way to link this data layer into MVC. I've considered a few options: *Datastore interacts with Model* //controller public function update() { $model = $this-loadModel('foo'); $data = $this-loadDataStore('foo', $model); $data-loadBar(9); //loads data and populates Model $model-setBar('bar'); $data-save(); //reads data from Model and saves } *Controller mediates between Model and Datastore* Seems a bit verbose and requires the model to know that a datastore exists. //controller public function update() { $model = $this-loadModel('foo'); $data = $this-loadDataStore('foo'); $model-setDataStore($data); $model-getDataStore-loadBar(9); //loads data and populates Model $model-setBar('bar'); $model-getDataStore-save(); //reads data from Model and saves } *Datastore extends Model* What happens if we want to save a Model extending a database datastore to a flatfile datastore? //controller public function update() { $model = $this-loadHybrid('foo'); //get_class == Datastore_Database $model-loadBar(9); //loads data and populates $model-setBar('bar'); $model-save(); //saves } *Model extends datastore* This allows for Model portability, but it seems wrong to extend like this. Further, the datastore cannot make use of any of the Model's methods. //controller extends model public function update() { $model = $this-loadHybrid('foo'); //get_class == Model $model-loadBar(9); //loads data and populates $model-setBar('bar'); $model-save(); //saves } Any input on the best option - or alternative - would be most appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, Ok. so you only need to retrieve those that the user is interested in, which is shown by what they click on. The relation between click and the display of the corresponded array child elements, without using js, is the hardest to understand: The user will click on a link / the URL will change / the new page will be loaded to the user / the information displayed on that page should be related with the element clicked on the first step. So, the next page, should know what we have clicked before, in order to display the information accordingly. One of the ways that this can be done, is by passing params over the URL. The URL param will tell us what element have we clicked, so it should be based on URL. Once we have that, we need to ask: as that value passed on the url a correspondent array element that contains children? If so, display them. (I realize my incapacity of talking technically, by referring to pages and other odd entities. I'm sorry for that). Does the above makes any sense? Thanks a lot, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Tue, 2009-10-27 at 11:39 +, MEM wrote: That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, Ok. so you only need to retrieve those that the user is interested in, which is shown by what they click on. The relation between click and the display of the corresponded array child elements, without using js, is the hardest to understand: The user will click on a link / the URL will change / the new page will be loaded to the user / the information displayed on that page should be related with the element clicked on the first step. So, the next page, should know what we have clicked before, in order to display the information accordingly. One of the ways that this can be done, is by passing params over the URL. The URL param will tell us what element have we clicked, so it should be based on URL. Once we have that, we need to ask: as that value passed on the url a correspondent array element that contains children? If so, display them. (I realize my incapacity of talking technically, by referring to pages and other odd entities. I'm sorry for that). Does the above makes any sense? Thanks a lot, Márcio Think of it a bit like an online shop selling operating systems: 1) All the main OS's you sell are on the front page - Linux, MacOS Windows 2) User clicks on Linux, and is taken to the url /products/linux and they are shown all the Linux OS's on offer (Fedora, SuSe, Ubuntu, Knoppix, etc) 3) User clicks on Fedora and is taken to the URL /products/linux/fedora and they are shown all the versions of Fedora up to 11 4) etc The URL belies what section you are on, which makes it easy for the user to remember, and easy for you to extract information from to know exactly where the user is. Obviously in the above URLs I'm assuming mod_rewrite is being used. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
Think of it a bit like an online shop selling operating systems: 1) All the main OS's you sell are on the front page - Linux, MacOS Windows 2) User clicks on Linux, and is taken to the url /products/linux and they are shown all the Linux OS's on offer (Fedora, SuSe, Ubuntu, Knoppix, etc) 3) User clicks on Fedora and is taken to the URL /products/linux/fedora and they are shown all the versions of Fedora up to 11 4) etc The URL belies what section you are on, which makes it easy for the user to remember, and easy for you to extract information from to know exactly where the user is. Obviously in the above URLs I'm assuming mod_rewrite is being used. Thanks, Ash http://www.ashleysheridan.co.uk Thanks a lot! Really. I will now start coding based on all this information and see what I will get. I'm sure that the designer will kill me later, by telling me... couldn't we just... fade in this a little bit... Ahhrrggg!!! Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP+Apache suddenly not working
I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/ zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1- RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with- config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable- libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '-- program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/ apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '-- prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/ info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+Apache suddenly not working
On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1 The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php create a small file with this code ?php phpinfo(); ? which will tell you want modules are enabled in php -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP+Apache suddenly not working
Jason Lixfeld wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. Are you sure you selected the Apache mod in make config? 1. go to /usr/ports/lang/php5 2. make deinstall 3. make config 4. select APACHE MODULES 5. select ok 6. make clean install -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP+Apache suddenly not working
On 2009-10-27, at 9:33 AM, Shawn McKenzie wrote: Jason Lixfeld wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. Are you sure you selected the Apache mod in make config? 1. go to /usr/ports/lang/php5 2. make deinstall 3. make config 4. select APACHE MODULES 5. select ok 6. make clean install Yup. Checked and double checked. It's there. Will do the make deinstall ; make clean install again though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+Apache suddenly not working
On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php create a small file with this code ?php phpinfo(); ? which will tell you want modules are enabled in php -- Bastien Cat, the other other white meat He already mentioned that phpinfo() fails. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] What is the best practice for adding persistence to an MVC model?
I take a different approach : // In the MainHandler Define('StorageClassName',_MySQL); Class UserController { function __construct($objDataStore=false){ if(!$objDataStore) $this-DataStore = new instanceof($this).STORAGECLASSNAME ; } Function update(){ $data = $this-DataStore-Load(foo); $data-Set(foo,bar); $data-save; } This assumes your using DBO so the loaded foo object inherited the settings/methods from the DB Datastore. Thus letting you passing a different datastore object or it builds one based on the model name and the storage type you set as a constant. However it still links the two together so you can use $this calls to reference the DataStore of the Model layer. David -Original Message- From: Mert Oztekin [mailto:mozte...@anadolusigorta.com.tr] Sent: Tuesday, October 27, 2009 6:14 AM To: 'Eric Bauman'; php-general@lists.php.net Subject: RE: [PHP] What is the best practice for adding persistence to an MVC model? Hi Eric, IMO, controllers shouldnt be responsible for interacting models and datastoreres. Controllers might only change the datastore class of a model. You may use your models in lots of controller functions. Defining datastore in all controllers seems not a good practice. (too much unneccessary codes written) A simple example //controller Public function doItController() { $user = new user(); // $user-setDataStorer(new anotherDataStorer()); // this is optional if you want to change models datastorer $user-loadUserFromId(1); } // model Class user { Protected $_dataStorer = null; Public function loadUserFromId($id = 0) { // codes codes codes $result = $this-getDataStorer()-query(select .); // codes codes codes } // codes codes codes Public function getDataStorer() { if(null == $this-_dataStorer) $this-_dataStorer = new myVeryBestDataStorer(); return $this-_dataStorer; } Public function setDataStorer($newStorer) { $this-_dataStorer = $newStorer; } } Hope it will be usefull and understandable -Original Message- From: Eric Bauman [mailto:baum...@livejournal.dk] Sent: Tuesday, October 27, 2009 8:27 AM To: php-general@lists.php.net Subject: [PHP] What is the best practice for adding persistence to an MVC model? I'm in the process of implementing an ultra-light MVC framework in PHP. It seems to be a common opinion that the loading of data from a database, file etc. should be independent of the Model, and I agree. What I'm unsure of is the best way to link this data layer into MVC. I've considered a few options: *Datastore interacts with Model* //controller public function update() { $model = $this-loadModel('foo'); $data = $this-loadDataStore('foo', $model); $data-loadBar(9); //loads data and populates Model $model-setBar('bar'); $data-save(); //reads data from Model and saves } *Controller mediates between Model and Datastore* Seems a bit verbose and requires the model to know that a datastore exists. //controller public function update() { $model = $this-loadModel('foo'); $data = $this-loadDataStore('foo'); $model-setDataStore($data); $model-getDataStore-loadBar(9); //loads data and populates Model $model-setBar('bar'); $model-getDataStore-save(); //reads data from Model and saves } *Datastore extends Model* What happens if we want to save a Model extending a database datastore to a flatfile datastore? //controller public function update() { $model = $this-loadHybrid('foo'); //get_class == Datastore_Database $model-loadBar(9); //loads data and populates $model-setBar('bar'); $model-save(); //saves } *Model extends datastore* This allows for Model portability, but it seems wrong to extend like this. Further, the datastore cannot make use of any of the Model's methods. //controller extends model public function update() { $model = $this-loadHybrid('foo'); //get_class == Model $model-loadBar(9); //loads data and populates $model-setBar('bar'); $model-save(); //saves } Any input on the best option - or alternative - would be most appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin
Re: [PHP] PHP+Apache suddenly not working
Ashley Sheridan wrote: On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php create a small file with this code ?php phpinfo(); ? which will tell you want modules are enabled in php -- Bastien Cat, the other other white meat He already mentioned that phpinfo() fails. Thanks, Ash http://www.ashleysheridan.co.uk No, he mentioned that the page that he navigates to fails. My best guess would be that he is getting a fatal error, like he mentioned above, which is preventing the output of the phpinfo() to be displayed. He needs a stripped down file that has nothing but this in it. ?php error_reporting(E_ALL); ini_set('display_errors', 1); phpinfo(); ? If that still doesn't work, the op needs to set the error level and error reporting options in his php.ini so it will
Re: [PHP] What is the best practice for adding persistence to an MVC model?
On Tue, Oct 27, 2009 at 05:27:07PM +1100, Eric Bauman wrote: I'm in the process of implementing an ultra-light MVC framework in PHP. It seems to be a common opinion that the loading of data from a database, file etc. should be independent of the Model, and I agree. What I'm unsure of is the best way to link this data layer into MVC. I disagree. There should be database class(es) which know how to deal with the datastore(s). This may be as simple as a thin layer over the PDO classes. The model talks to and uses the database class, and is the only component which deals with the database class. The model serves up whatever data the controller needs to feed to the view. All are welcome to disagree. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the best practice for adding persistence to an MVC model?
2009/10/27 Paul M Foster pa...@quillandmouse.com: On Tue, Oct 27, 2009 at 05:27:07PM +1100, Eric Bauman wrote: I'm in the process of implementing an ultra-light MVC framework in PHP. It seems to be a common opinion that the loading of data from a database, file etc. should be independent of the Model, and I agree. What I'm unsure of is the best way to link this data layer into MVC. I disagree. There should be database class(es) which know how to deal Paul, you already did this in one of Eric's threads a couple of weeks back, and the best you could come up with when pressed was Probably not a great example, but Is it really necessary to rehash this? Eric, I recommend reading up on how to develop testable code (especially Mock Objects) - it's great discipline because it requires everything to be decoupled. The short version is that it's often useful in unit testing to fake the classes that your target relies on, so that you're testing it in isolation. For example you could provide the class under test with a fake DB class that returns static results. It's much easier to do this when you pass objects /to/ your class: class MyClass { function MyClass($db) { } } than when your class inherits from the object: class MyClass extends Db { } or when the class instantiates the object: class MyClass { function MyClass() { $this-db = new DB_CLASS; } } If you go with the first approach, you're writing code that you and anyone who comes after you can write useful tests for. The others, and you're denying maintenance programmers a useful tool. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP+Apache suddenly not working
Hi all, If the basic functions of php not work, maybe the extension for php5 or 4 are disabled, or the library is missing, sometimes apache does not show the erros for missing library, or yet, the library for php4 or 5 are both on, or they crash Yuri Yarlei. www.yuriyarlei.net (under construction) Programmer PHP, JAVA, CSS, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Tue, 27 Oct 2009 07:59:16 -0700 From: li...@cmsws.com To: a...@ashleysheridan.co.uk CC: phps...@gmail.com; jason-lists@lixfeld.ca; php-general@lists.php.net Subject: Re: [PHP] PHP+Apache suddenly not working Ashley Sheridan wrote: On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1 The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
RE: [PHP] PHP+Apache suddenly not working
Hi all, If the basic functions of php not work, maybe the extension for php5 or 4 are disabled, or the library is missing, sometimes apache does not show the erros for missing library, or yet, the library for php4 or 5 are both on, or they crash Yuri Yarlei. www.yuriyarlei.net (under construction) Programmer PHP, JAVA, CSS, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Tue, 27 Oct 2009 07:59:16 -0700 From: li...@cmsws.com To: a...@ashleysheridan.co.uk CC: phps...@gmail.com; jason-lists@lixfeld.ca; php-general@lists.php.net Subject: Re: [PHP] PHP+Apache suddenly not working Ashley Sheridan wrote: On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1 The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php [r...@ricky /]# Any ideas for a completely ignorant, non-developer type? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
RE: [PHP] PHP+Apache suddenly not working
On Tue, 2009-10-27 at 19:16 +0300, Yuri Yarlei wrote: Hi all, If the basic functions of php not work, maybe the extension for php5 or 4 are disabled, or the library is missing, sometimes apache does not show the erros for missing library, or yet, the library for php4 or 5 are both on, or they crash Yuri Yarlei. www.yuriyarlei.net (under construction) Programmer PHP, JAVA, CSS, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Tue, 27 Oct 2009 07:59:16 -0700 From: li...@cmsws.com To: a...@ashleysheridan.co.uk CC: phps...@gmail.com; jason-lists@lixfeld.ca; php-general@lists.php.net Subject: Re: [PHP] PHP+Apache suddenly not working Ashley Sheridan wrote: On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1 The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php php5-mysql-5.2.11_1 The mysql shared extension for php php5-openssl-5.2.11_1 The openssl shared extension for php php5-pcre-5.2.11_1 The pcre shared extension for php php5-pdo-5.2.11_1 The pdo shared extension for php php5-pdo_sqlite-5.2.11_1 The pdo_sqlite shared extension for php php5-posix-5.2.11_1 The posix shared extension for php php5-session-5.2.11_1 The session shared extension for php php5-simplexml-5.2.11_1 The simplexml shared extension for php php5-spl-5.2.11_1 The spl shared extension for php php5-sqlite-5.2.11_1 The sqlite shared extension for php php5-tokenizer-5.2.11_1 The tokenizer shared extension for php php5-xml-5.2.11_1 The xml shared extension for php php5-xmlreader-5.2.11_1 The xmlreader shared extension for php php5-xmlwriter-5.2.11_1 The xmlwriter shared extension for php
[PHP] Unsuscribe
I want a list in spanish about PHP Thank you Manuel.morini -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the best practice for adding persistence to an MVC model?
On Tue, Oct 27, 2009 at 04:11:32PM +, David Otton wrote: 2009/10/27 Paul M Foster pa...@quillandmouse.com: On Tue, Oct 27, 2009 at 05:27:07PM +1100, Eric Bauman wrote: I'm in the process of implementing an ultra-light MVC framework in PHP. It seems to be a common opinion that the loading of data from a database, file etc. should be independent of the Model, and I agree. What I'm unsure of is the best way to link this data layer into MVC. I disagree. There should be database class(es) which know how to deal Paul, you already did this in one of Eric's threads a couple of weeks back, and the best you could come up with when pressed was Probably not a great example, but Is it really necessary to rehash this? I don't track threads closely enough to know if it's the same OP on this thread. Apologies if I'm repeating myself. I don't recall anyone disputing my example, nor any effective rebuttal at all. And by the time I finished writing that email, I thought it was a better example than I originally believed. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP+Apache suddenly not working
Ash, I think the apache is working, because he recieve the error [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function, if apache are not started he will receive some error about apache starting or someting like that. Yuri Yarlei. http://www.yuriyarlei.net.net (under construction) Programmer PHP, JAVA, CSS, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. From: a...@ashleysheridan.co.uk To: gargari...@hotmail.com CC: li...@cmsws.com; phps...@gmail.com; jason-lists@lixfeld.ca; php-general@lists.php.net Date: Tue, 27 Oct 2009 16:20:45 + Subject: RE: [PHP] PHP+Apache suddenly not working On Tue, 2009-10-27 at 19:16 +0300, Yuri Yarlei wrote: Hi all, If the basic functions of php not work, maybe the extension for php5 or 4 are disabled, or the library is missing, sometimes apache does not show the erros for missing library, or yet, the library for php4 or 5 are both on, or they crash Yuri Yarlei. www.yuriyarlei.net (under construction) Programmer PHP, JAVA, CSS, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Tue, 27 Oct 2009 07:59:16 -0700 From: li...@cmsws.com To: a...@ashleysheridan.co.uk CC: phps...@gmail.com; jason-lists@lixfeld.ca; php-general@lists.php.net Subject: Re: [PHP] PHP+Apache suddenly not working Ashley Sheridan wrote: On Tue, 2009-10-27 at 09:24 -0400, Bastien Koert wrote: On Tue, Oct 27, 2009 at 9:18 AM, Jason Lixfeld jason-lists@lixfeld.ca wrote: I have no doubt that this is due to an update that was done on my system at some point, but unfortunately I can't pinpoint where. The upshot is that PHP is completely unresponsive for me when run from Apache and I'm not sure where to look. I recognize that this isn't an apache support list. This message is being cc'd there too. The system is FreeBSD 6.1-RELEASE-p15. PHP 5.2.11 from ports. The only error I get in my php log is this: [27-Oct-2009 13:05:00] PHP Fatal error: Call to undefined function preg_match() in /usr/home/foo/public_html/cerb4/libs/devblocks/libs/zend_framework/Zend/Cache/Backend/File.php on line 125 Now I've checked and double checked that pcre support is built into php. I'm not sure if there's a command that I can run in php to show all the extensions that are installed or something, but I'm a bazillion percent sure that it's there, so I don't believe that's the cause of the error. I'm reasonably sure of this because the preg_match error thrown every minute when a cron job runs, I have a .php that calls phpinfo() that shows a blank screen when hit from a browser. My problem is that I don't know how to troubleshoot this. I can seem to run PHP from the CLI just fine, so does this look more like an apache issue or perhaps some php module or extension that talks to apache? [r...@ricky /]# php ?php phpinfo(); ? phpinfo() PHP Version = 5.2.11 System = FreeBSD ricky.arionetworks.ca 6.1-RELEASE-p15 FreeBSD 6.1-RELEASE-p15 #0: Sat Mar 31 11:43:34 EDT 2007 jlixf...@ricky.arionetworks.ca:/usr/src/sys/amd64/compile/GENERIC amd64 Build Date = Oct 26 2009 15:38:06 Configure Command = './configure' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--program-prefix=' '--enable-fastcgi' '--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd6.1' Server API = Command Line Interface Virtual Directory Support = disabled Configuration File (php.ini) Path = /usr/local/etc Loaded Configuration File = /usr/local/etc/php.ini Scan this dir for additional .ini files = /usr/local/etc/php additional .ini files parsed = /usr/local/etc/php/extensions.ini ... ... ... etc ... [r...@ricky /]# pkg_info | grep php5 php5-5.2.11_1 PHP Scripting Language php5-ctype-5.2.11_1 The ctype shared extension for php php5-dom-5.2.11_1 The dom shared extension for php php5-extensions-1.3 A meta-port to install PHP extensions php5-filter-5.2.11_1 The filter shared extension for php php5-gd-5.2.11_1 The gd shared extension for php php5-gettext-5.2.11_1 The gettext shared extension for php php5-iconv-5.2.11_1 The iconv shared extension for php php5-imap-5.2.11_1 The imap shared extension for php php5-ldap-5.2.11_1 The ldap shared extension for php php5-mbstring-5.2.11_1 The mbstring shared extension for php
Re: [PHP] What is the best practice for adding persistence to an MVC model?
2009/10/27 David Otton phpm...@jawbone.freeserve.co.uk: If you go with the first approach, you're writing code that you and anyone who comes after you can write useful tests for. The others, and you're denying maintenance programmers a useful tool. I should have lead with this: the wikipedia article on Dependency injection http://en.wikipedia.org/wiki/Dependency_injection -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unsuscribe
Manuel Morini schreef: I want a list in spanish about PHP Thank you Manuel.morini Try php.general.es. -- Mark Cilissen / Pixlism http://www.ninyou.nl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple xml object
AChris W schreef: I have the following xmlwith standard tags changed to [ and ] to prevent mail clients from encoding it as html. [?xml version=1.0?] [resultset errors=0 results=86] [result id=20080922133104871678 lastinspected=9/29/2009 0:00]0.4[/result] [result id=20080922133104871678 lastinspected=8/28/2009 0:00]1.1[/result] . . . I am using the simplexml_load_string to read it in to an object and execute the following code $xml = simplexml_load_string($content); foreach($xml as $Result){ print_r($Result); foreach($Result-attributes() as $i = $v){ $$i = $v; print Attr: $i = '$v'\n; } } that all works fine. Problem is I can't figure out how to get the acutual value (0.4 and 1.1). I also don't know why I can't simply do something like $id = $Result-attributes()-id; the output of this looks like SimpleXMLElement Object ( [...@attributes] = Array ( [id] = 20080922133104871678 [lastinspected] = 9/29/2009 0:00 ) [0] = 0.4 ) Attr: id = '20080922133104871678' Attr: lastinspected = '9/29/2009 0:00' SimpleXMLElement Object ( [...@attributes] = Array ( [id] = 20080922133104871678 [lastinspected] = 8/28/2009 0:00 ) [0] = 1.1 ) Attr: id = '20080922133104871678' Attr: lastinspected = '8/28/2009 0:00' How do I read the [0] value? $Result[0] gives me nothing. Although I'm not that familiar with SimpleXML, since the value returned is an object, wouldn't $Result-0 do the trick? -- Kind regards, Mark Cilissen / Pixlism http://www.ninyou.nl -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cookie Quandary
I wrote some cookies for a whole bunch of site admins, but failed to set the path, so all the cookies are set to '/admin', which is not going to work for everything they need to do. They are also too long, set for 6 months. I need to correct both issues, so I changed it to write cookies to '/' for 72 hours. I've checked my Safari, and I see that I have both cookies set: A long one for '/admin' and a short one for '/'. I'm worried that once the admins' short cookies run out, their browsers will pick up the longer lasting value for the '/admin' version of the cookie. I want to kill everyones' '/admin' cookies, but I'm worried that some browsers might erase both cookies if I do this. Does anyone know if I can safely kill the '/admin' cookie without risking deletion of the '/' cookie? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie Quandary
On Tue, 2009-10-27 at 10:35 -0700, Brian Dunning wrote: I wrote some cookies for a whole bunch of site admins, but failed to set the path, so all the cookies are set to '/admin', which is not going to work for everything they need to do. They are also too long, set for 6 months. I need to correct both issues, so I changed it to write cookies to '/' for 72 hours. I've checked my Safari, and I see that I have both cookies set: A long one for '/admin' and a short one for '/'. I'm worried that once the admins' short cookies run out, their browsers will pick up the longer lasting value for the '/admin' version of the cookie. I want to kill everyones' '/admin' cookies, but I'm worried that some browsers might erase both cookies if I do this. Does anyone know if I can safely kill the '/admin' cookie without risking deletion of the '/' cookie? Cookies are client-side. Do you mean session files? Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: Unsuscribe
Manuel Morini schreef: I want a list in spanish about PHP Thank you Manuel.morini Try php.general.es. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie Quandary
No, I'm talking about cookies, thus the references to pathnames and expirations. On Oct 27, 2009, at 10:56 AM, Ashley Sheridan wrote: Cookies are client-side. Do you mean session files? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie Quandary
On Tue, 2009-10-27 at 11:34 -0700, Brian Dunning wrote: No, I'm talking about cookies, thus the references to pathnames and expirations. On Oct 27, 2009, at 10:56 AM, Ashley Sheridan wrote: Cookies are client-side. Do you mean session files? How are you writing the cookies to a users local computer? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Cookie Quandary
Brian Dunning wrote: I want to kill everyones' '/admin' cookies, but I'm worried that some browsers might erase both cookies if I do this. Does anyone know if I can safely kill the '/admin' cookie without risking deletion of the '/' cookie? How about you store the data, expire both cookies then send the valid cookie back to the browser? -- John All truth is simple... is that not doubly a lie? [Friedrich Nietzsche] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+Apache suddenly not working
Thanks for the replies guys. As a few have eluded to, Apache is working fine. What I've done is completely uninstalled, made clean from source, reinstalled and verified that the options were such that apache support is built into PHP and Apache. Here's what I've found: Apache seems to be compiled with the proper PHP support: blackbox:~ jlixfeld$ telnet ricky 80 Trying 172.16.17.2... Connected to ricky.arionetworks.ca. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Tue, 27 Oct 2009 13:38:53 GMT Server: Apache/2.2.13 (FreeBSD) mod_ssl/2.2.13 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.11 with Suhosin-Patch Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT ETag: c77455-2c-3e9564c23b600 Accept-Ranges: bytes Content-Length: 44 Connection: close Content-Type: text/html Connection closed by foreign host. blackbox:~ jlixfeld$ PHP seems to want to compile against the proper Apache libs as can be seen from the make | grep -i apache and the make install: checking for Apache 1.x module support via DSO through APXS... no checking for Apache 1.x module support... no checking whether to enable Apache charset compatibility option... no checking for Apache 2.0 filter-module support via DSO through APXS... no checking for Apache 2.0 handler-module support via DSO through APXS... yes checking for Apache 1.x (hooks) module support via DSO through APXS... no checking for Apache 1.x (hooks) module support... no checking whether to enable Apache charset compatibility option... no checking whether to force Apache CGI redirect... no checking for chosen SAPI module... apache2handler [r...@ricky /usr/ports/lang/php5]# make install === Installing for php5-5.2.11_1 === php5-5.2.11_1 depends on file: /usr/local/sbin/apxs - found === php5-5.2.11_1 depends on executable: pkg-config - found === php5-5.2.11_1 depends on shared library: xml2.5 - found === Generating temporary packing list === Checking if lang/php5 already installed Makefile, line 565: warning: duplicate script for target main/ internal_functions.lo ignored Installing PHP SAPI module: apache2handler /usr/local/share/apache22/build/instdso.sh SH_LIBTOOL='/usr/local/ share/apr/build-1/libtool' libphp5.la /usr/local/libexec/apache22 /usr/local/share/apr/build-1/libtool --mode=install cp libphp5.la /usr/ local/libexec/apache22/ libtool: install: cp .libs/libphp5.so /usr/local/libexec/apache22/ libphp5.so libtool: install: cp .libs/libphp5.lai /usr/local/libexec/apache22/ libphp5.la libtool: install: warning: remember to run `libtool --finish /usr/ ports/lang/php5/work/php-5.2.11/libs' chmod 755 /usr/local/libexec/apache22/libphp5.so [activating module `php5' in /usr/local/etc/apache22/httpd.conf] Installing PHP CLI binary:/usr/local/bin/ Installing PHP CLI man page: /usr/local/man/man1/ Installing PHP CGI binary: /usr/local/bin/ Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config Installing man pages: /usr/local/man/man1/ page: phpize.1 page: php-config.1 *** Make sure index.php is part of your DirectoryIndex. You should add the following to your Apache configuration file: AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps *** === Compressing manual pages for php5-5.2.11_1 === Registering installation for php5-5.2.11_1 === SECURITY REPORT: This port has installed the following files which may act as network servers and may therefore pose a remote security risk to the system. /usr/local/libexec/apache22/libphp5.so /usr/local/bin/php /usr/local/bin/php-cgi If there are vulnerabilities in these programs there may be a security risk to the system. FreeBSD makes no guarantee about the security of ports included in the Ports Collection. Please type 'make deinstall' to deinstall the port if this is a concern. For more information, and contact details about the security status of this software, see the following webpage: http://www.php.net/ [r...@ricky /usr/ports/lang/php5]# ls -al /usr/local/libexec/apache22/ libphp5.so -rwxr-xr-x 1 root wheel 3114971 Oct 27 14:51 /usr/local/libexec/ apache22/libphp5.so [r...@ricky /usr/ports/lang/php5]# Someone mentioned setting the php.ini up so it could display errors in the browser. How do I go about that? My php.ini looks like this. I don't see errors in there when I try to hit the phpinfo file with the browser, but I do get the error I reported in the OP which is a cronjob running wget on something that complains about pcre (which is a mystery in and of itself considering pcre is a installed properly too :| [r...@ricky /usr/local/www]# cat /usr/local/etc/php.ini | egrep -i
[PHP] Converting MySQL into Form
Anyone know of a way to can take Mysql tables/fields from phpMyAdmin or .sql file and quickly make into HTML forms?
[PHP] What would stop header(Location...) from working?
Hi gang: I just had a script stop following this statement: header(Location:users.php); It *was* working, but now instead of running users.php, it defaults to the parent script. When I place exit() after it, such as: header(Location:users.php); exit(); The script simply exits. It does not continue to users.php -- BUT -- it did. What would stop this statement from working? Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What would stop header(Location...) from working?
On Wed, Oct 28, 2009 at 10:01 AM, tedd t...@sperling.com wrote: I just had a script stop following this statement: header(Location:users.php); It *was* working, but now instead of running users.php, it defaults to the parent script. When I place exit() after it, such as: header(Location:users.php); exit(); The script simply exits. It does not continue to users.php -- BUT -- it did. What would stop this statement from working? Any text output before the header() statement would stop it, this includes spaces after closing ? in any included files before the header() as well, not just text from echos or prints. If you have errors hidden or disabled, then you would not see the warning from header(), try it with all errors enabled. Cheers, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to Get the Sub Classes of a Parent Class
David, I'm try to do something like what Martin Scotta did but I'm looking for a solution that did not require me to loop through get_declared classes() to find a sub class. __ Raymond Irving From: David Otton phpm...@jawbone.freeserve.co.uk To: Raymond Irving xwis...@yahoo.com Cc: PHP-General List php-general@lists.php.net Sent: Mon, October 26, 2009 8:33:02 PM Subject: Re: [PHP] How to Get the Sub Classes of a Parent Class 2009/10/27 Raymond Irving xwis...@yahoo.com: I want to automatically initialize a specific sub class when the php page is loaded. You may be able solve this with a simple class_exists() (pseudo-code ahead): if(class_exists($var)) { $class = new $var; } else { $class = new FourOhFour; } This works if you know the name of the class. What I'm looking for is a way to get one of the sub classes and initialize it dynamically. I'm confused. If you don't know the name of the child class, how are you going to know which one to instantiate? Are you going to pick one at random? What you're trying to do can probably be accomplished, but I can't shake the feeling we're trying to solve the wrong problem here.
Re: [PHP] How to Get the Sub Classes of a Parent Class
Hi Martin, This works great but I was hoping that I didn't have to loop through get_declared_classes to find the sub class. Is there a way to get the subclasses using Reflection? For example: $r = new ReflectionClass($name); print_r($r-getSubClasses()); Many Thanks From: Martin Scotta martinsco...@gmail.com To: Raymond Irving xwis...@yahoo.com Cc: David Otton phpm...@jawbone.freeserve.co.uk; PHP-General List php-general@lists.php.net Sent: Mon, October 26, 2009 8:34:05 PM Subject: Re: [PHP] How to Get the Sub Classes of a Parent Class On Mon, Oct 26, 2009 at 10:22 PM, Raymond Irving xwis...@yahoo.com wrote: This works if you know the name of the class. What I'm looking for is a way to get one of the sub classes and initialize it dynamically. From: David Otton phpm...@jawbone.freeserve.co.uk To: Raymond Irving xwis...@yahoo.com Cc: PHP-General List php-general@lists.php.net Sent: Sun, October 25, 2009 10:25:27 AM Subject: Re: [PHP] How to Get the Sub Classes of a Parent Class 2009/10/25 Raymond Irving xwis...@yahoo.com: I want to automatically initialize a specific sub class when the php page is loaded. I'm looking for a solution for php 5.1+ or anything that's optimized for 5.3 You may be able solve this with a simple class_exists() (pseudo-code ahead): if(class_exists($var)) { $class = new $var; } else { $class = new FourOhFour; } This script only works for loaded classes . If your script has autoloader then there is no way to know the declared classes before you declare them. error_reporting( E_ALL | E_STRICT ); Class Foo {} Class Bar extends Foo {} Class Baz extends Foo {} Class Beer extends Bar {} Class Pier extends Bar {} function get_subclasses($class) { $sub = array(); foreach(get_declared_classes() as $name ) { $rClass = new ReflectionClass($name); if( $rClass-isSubclassOf( $class )) { $sub[] = $name; } } return $sub; } print_r( get_subclasses( 'Foo' )); print_r( get_subclasses( 'Bar' )); -- Martin Scotta
[PHP] Netbeans IDE 6.5
Hey all, I just downloaded the Netbeans 6.5 IDE to use as a code editor, installed the PHP plugin for syntax highlighting and it didn't look so good, so I find on the forum a guy who has made a collection of files, starting in a directory called config, that will apparently change the highlighting more in line to what I'm used to. But he gave no instructions how this is to be installed and I can't find anywhere in the documentation how to install this stuff. Any Netbeaners out there know how to install syntax highlighting stuff? I found it here. http://forums.netbeans.org/post-46850.html Downloaded and unzipped the archive and then I stopped like the robot on Lost in Space when they pulled out his power pack. Any help would be great! Thanks, Skip -- Skip Evans PenguinSites.com, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://penguinsites.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Converting tables into forms
Does anyone have a quick way of converting tables into forms? -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to Get the Sub Classes of a Parent Class
On Tue, Oct 27, 2009 at 9:30 PM, Raymond Irving xwis...@yahoo.com wrote: Hi Martin, This works great but I was hoping that I didn't have to loop through get_declared_classes to find the sub class. Is there a way to get the subclasses using Reflection? For example: $r = new ReflectionClass($name); print_r($r-getSubClasses()); Many Thanks -- *From:* Martin Scotta martinsco...@gmail.com *To:* Raymond Irving xwis...@yahoo.com *Cc:* David Otton phpm...@jawbone.freeserve.co.uk; PHP-General List php-general@lists.php.net *Sent:* Mon, October 26, 2009 8:34:05 PM *Subject:* Re: [PHP] How to Get the Sub Classes of a Parent Class On Mon, Oct 26, 2009 at 10:22 PM, Raymond Irving xwis...@yahoo.comwrote: This works if you know the name of the class. What I'm looking for is a way to get one of the sub classes and initialize it dynamically. From: David Otton phpm...@jawbone.freeserve.co.uk To: Raymond Irving xwis...@yahoo.com Cc: PHP-General List php-general@lists.php.net Sent: Sun, October 25, 2009 10:25:27 AM Subject: Re: [PHP] How to Get the Sub Classes of a Parent Class 2009/10/25 Raymond Irving xwis...@yahoo.com: I want to automatically initialize a specific sub class when the php page is loaded. I'm looking for a solution for php 5.1+ or anything that's optimized for 5.3 You may be able solve this with a simple class_exists() (pseudo-code ahead): if(class_exists($var)) { $class = new $var; } else { $class = new FourOhFour; } This script only works for loaded classes . If your script has autoloader then there is no way to know the declared classes before you declare them. error_reporting( E_ALL | E_STRICT ); Class Foo {} Class Bar extends Foo {} Class Baz extends Foo {} Class Beer extends Bar {} Class Pier extends Bar {} function get_subclasses($class) { $sub = array(); foreach(get_declared_classes() as $name ) { $rClass = new ReflectionClass($name); if( $rClass-isSubclassOf( $class )) { $sub[] = $name; } } return $sub; } print_r( get_subclasses( 'Foo' )); print_r( get_subclasses( 'Bar' )); -- Martin Scotta Hi Raymon I think your main problem here is that you do not know which class you will instantiate. This can lead to undefined behaviour. Maybe you need to re-analyse your solution. cheers, Martin Scotta
Re: [PHP] Converting tables into forms
ben...@gmail.com wrote: Does anyone have a quick way of converting tables into forms? *tongue in cheek* PHPMyAdmin. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting tables into forms
Hi Ben The quickest way to this is by using a framework. and the best way i could find was using the yiiframework www.yiiframework.com i could create a basic form with validations in less then 15 minutes. On Wed, Oct 28, 2009 at 6:42 AM, ben...@gmail.com ben...@gmail.com wrote: Does anyone have a quick way of converting tables into forms? -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- with regards, Chetan Dattaram Rane Mob : +91 9766646714 Phone: 0831-2462055
Re: [PHP] input form save and display conflict
Ashley Sheridan wrote: On Thu, 2009-10-22 at 21:32 -0400, PJ wrote: I have several input fields to update a book database. There seems to be a conflict in the way tags and text are input through php/mysql and phpMyAdmin. If I enter the data with phpMyAdmin the input fields in the php page see quotation marks differently than what is input in phpMyAdmin. example: if the data is input through the update form, single quotes cause an error. Double quotes update the db but when the edit(update) form displays the text for modification outside the input field except for the first part, precisely where the first quotation mark appears in the text - as below: *bReviewed by a href=*mailto:recipi...@somewhere.com;Recipient: blah, blah, blah...religion. _size=50 /_ The text in square brackets is displayed outside the input field and includes part of the code at the end. bold is within the field, the rest is outside and the underlined is part of code. If the same text is entered with phpMyAdmin using single quotes and the quot; characters, the display in the editing field shows correctly... but it will not update, that is, the update query generates errors and only accepts the double quotes within the tags. So, the question is, are there some kind of metacharacters to be used to have mysql accept the ? I have triee backslashing, forward slashing and they don't do it. Or is there an encoding conflict here? It looks like a display and save mismatch somewhere... below is another example: a href='http://www.amazon.com/exec/obidos/ASIN/0773468943/frankiesbibliogo' http://www.amazon.com/exec/obidos/ASIN/0773468943/frankiesbibliogo%27IMG height=68 alt=Order This Book From Amazon.com src=../images/amazon1.gif width=90 border=0 //a The single quotes for the href seem to work. But the does not work; and using quot; or rsquo; also also do not display correctly; again, from Order... the image is not displayed but only the image blank with Order.. in it. I'm rather puzzled. Single quotes need to be escaped if you are using them as part of a query. For example: $query = UPDATE table SET title='This is a title with \quoted\ \'characters\''; Note that here, double quotes are used to encapsulate the whole query string (as it is generally preferred this way), the value of the title field is encapsulated in single quotes. Lastly, where I've wanted double quotes to be used in the query, I've escaped them with a back-slash. This escapes them from PHP, as mysql is using single quotes, so directly in the query they're fine. The single quotes are also escaped with back-slashes, but this time to escape them from mysql, as single quotes are used as the string delimiters there. I've had a chance to think about the problem and I think this will fix it. The edit page retieves the form input variable = commentIN and echos to the browser. The problem is that the browser displays commentIN without the the backslashes and that is what is then resubmitted if the submit is execcuted (without the slashes). Therefore, it seems to me, I must use preg_replace to add the \ to the single quotes in the commentIN variable just before the update query... My only question, then, is how do I do the preg_replace in the commentIN . Is it something like $commentIN = (act on $commentIN) or do I have to do a $another_name = (preg_whatever, $commentIN and then reassign $commentIn = $another_name ? TIA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting tables into forms
I am trying to take MySQL tables and use the table structure to create HTML/PHP forms in as few steps as possible for further development. I have a project that has hundreds of tables and requires hundreds of forms to be created and don't want to do so field by field by hand. Thanks, Ben On Tuesday, October 27, 2009, Allen McCabe allenmcc...@gmail.com wrote: Please explain with much greater detail. On Tue, Oct 27, 2009 at 6:12 PM, ben...@gmail.com ben...@gmail.com wrote: Does anyone have a quick way of converting tables into forms? -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Converting tables into forms
On Wed, Oct 28, 2009 at 2:37 PM, ben...@gmail.com ben...@gmail.com wrote: I am trying to take MySQL tables and use the table structure to create HTML/PHP forms in as few steps as possible for further development. I have a project that has hundreds of tables and requires hundreds of forms to be created and don't want to do so field by field by hand. With a little coding, Zend_Form should do what you need. http://framework.zend.com/manual/en/zend.form.html Cheers, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Converting tables into forms
ben...@gmail.com wrote: I am trying to take MySQL tables and use the table structure to create HTML/PHP forms in as few steps as possible for further development. I have a project that has hundreds of tables and requires hundreds of forms to be created and don't want to do so field by field by hand. With hundreds of tables, if you don't find an existing solution that meets your needs, it sounds like it would be a good idea to design your own anyways. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php