Re: [PHP] Dependency Injection containers
Hi, you could simply write your own, you simply need a class or a function that given an identifier such as database.connector would return you an instance of it, and and maybe handle singletons. It just a question of taste of how you want it to be. I have just posted a few days ago my implementation, it might interest you (I think it should work with php 5.2) ?php class Dependency { protected $_singletonInstances = array(); protected $_setInstances = array(); protected $_configuration; protected static $_instance; public static function getInstance() { if (self::$_instance===null) { self::$_instance = new self(); } return self::$_instance; } public function setConfiguration(array $configuration) { $this-_configuration = $configuration; } public function getConfiguration() { return $this-_configuration; } public function __isset($serviceName) { return isset($this-_serviceInstances[$serviceName]); } public function __call($serviceName, $args) { // singleton if (isset($this-_configuration[$serviceName]) $this-_configuration[$serviceName]['singleton']) { if (!isset($this-_singletonInstances[$serviceName])) { $rc = new ReflectionClass($this-_configuration[$serviceName]['class']); $this-_singletonInstances[$serviceName] = empty($args) ? $rc-newInstance() : $rc-newInstanceArgs($args); } $ret = $this-_singletonInstances[$serviceName]; } else { // normal if (isset($this-_setInstances[$serviceName])) { $ret = $this-_setInstances[$serviceName]; unset($this-_setInstances[$serviceName]); } else { $rc = new ReflectionClass($this-_configuration[$serviceName]['class']); $ret = $this-_singletonInstances[$serviceName] = empty($args) ? $rc-newInstance() : $rc-newInstanceArgs($args); } } return $ret; } public function __get($serviceName) { return $this-__call($serviceName, array()); } public function __set($serviceName, $instance) { if (!is_object($instance)) throw new Exception('instance must be an object'); $this-_setInstances[$serviceName] = $instance; } } $di=Dependency::getInstance(); $di-setConfiguration(array( 'database.connector'=array( 'singleton'=true, 'class'='DatabaseConnector' ), 'database'=array( 'singleton'=true, 'class'='Database' ) )); class DatabaseConnector{} class Database{ protected $_connector; public function __construct(){ $this-setConnector(Dependency::getInstance()-{'database.connector'}); } public function setConnector($connector){ $this-_connector=$connector; } } class Test{ protected $_database; public function __construct(){ $this-setDatabase(Dependency::getInstance()-database); } public function setDatabase($db){ $this-_database=$db; } public function getDatabase(){ return $this-_database; } } $test=new Test(); var_dump($test-getDatabase()); regards, Jean-Baptiste Verrey On 31 October 2011 21:32, robert mena robert.m...@gmail.com wrote: Hi, I am trying to avoid reinventing the wheel so I am looking for dependency injection containers that work with PHP 5.2. So Symphony2 and ZF2 DI are out of question. I found this http://www.potstuck.com/2010/09/09/php-dependency-a-php-dependency-injection-framework/ but I was wondering if anyone has a opinion about it or alternatives. regards. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dependency Injection Implementation
Hi everyone, Dependency Injection is a very trendy subject and after reading about it I kinda thought about rewriting the framework I'm doing with dependency injection. So I made my own implementation and was wondering what would you think about it? I have followed the article of Martin Fowler ( http://martinfowler.com/articles/injection.html) with this implementation I have the following : - you have both constructor and setter injection - the Dependency class is a service locator - we have at the same time service locator AND dependency injection - you can always manually inject dependency - you can pass arguments to the injected object constructor So: am I missing something? Do you think it's good enough? here is the code : ?php class Dependency { protected $_singletonInstances = array(); protected $_setInstances = array(); protected $_configuration; public static function getInstance() { static $instance = NULL; if (NULL === $instance) { $instance = new static(); } return $instance; } public function setConfiguration(array $configuration) { $this-_configuration = $configuration; } public function getConfiguration() { return $this-_configuration; } public function __isset($serviceName) { return isset($this-_serviceInstances[$serviceName]); } public function __call($serviceName, $args) { // singleton if (isset($this-_configuration[$serviceName]) $this-_configuration[$serviceName]['singleton']) { if (!isset($this-_singletonInstances[$serviceName])) { $rc = new \ReflectionClass($this-_configuration[$serviceName]['class']); $this-_singletonInstances[$serviceName] = empty($args) ? $rc-newInstance() : $rc-newInstanceArgs($args); } $ret = $this-_singletonInstances[$serviceName]; } else { // normal if (isset($this-_setInstances[$serviceName])) { $ret = $this-_setInstances[$serviceName]; unset($this-_setInstances[$serviceName]); } else { $rc = new \ReflectionClass($this-_configuration[$serviceName]['class']); $ret = $this-_singletonInstances[$serviceName] = empty($args) ? $rc-newInstance() : $rc-newInstanceArgs($args); } } return $ret; } public function __get($serviceName) { return $this-__call($serviceName, array()); } public function __set($serviceName, $instance) { if (!is_object($instance)) throw new Exception('instance must be an object'); $this-_setInstances[$serviceName] = $instance; } } class DependencyInjectorException extends \Exception { } $di=DependencyInjector::getInstance(); $di-setConfiguration(array( 'database.connector'=array( 'singleton'=true, 'class'='DatabaseConnector' ), 'database'=array( 'singleton'=true, 'class'='Database' ) )); class DatabaseConnector{} class Database{ protected $_connector; public function __construct(){ $this-setConnector(DependencyInjector::getInstance()-{'database.connector'}); } public function setConnector($connector){ $this-_connector=$connector; } } class Test{ protected $_database; public function __construct(){ $this-setDatabase(DependencyInjector::getInstance()-database); } public function setDatabase($db){ $this-_database=$db; } public function getDatabase(){ return $this-_database; } } $test=new Test(); var_dump($test-getDatabase()); ?
Re: [PHP] Introducting CRUDsader : a new PHP ORM Framework
yes it's open source, it's under LGPL license! On 14 October 2011 03:52, Sharl.Jimh.Tsin amoiz.sh...@gmail.com wrote: 在 2011-10-13四的 19:06 +0100,jean-baptiste verrey写道: hi everyone, I have been developing an ORM framework for the last year (at least) and I have finally released a beta that is worth of being on internet^^ so if you have some time to spare have a look at http://www.crudsader.com/. The novelty of the framework lies in object automatic forms, configuration and the Object query language (which is very simple and uses string instead of object methods). It's missing cache and performance improvement at the moment but I'm working on it. I will gladly appreciate any comments to make it better, or about anything that the framework is missing or where I could have been completely wrong! Regards, Jean-Baptiste Verrey ps: I'm working hard on checking that the examples of the doc are actually working, and to add more content to the docs Great job,thanks a lot.is it open source? -- Best regards, Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**) Using Gmail? Please read this important notice: http://www.fsf.org/campaigns/jstrap/gmail?10073.
[PHP] Introducting CRUDsader : a new PHP ORM Framework
hi everyone, I have been developing an ORM framework for the last year (at least) and I have finally released a beta that is worth of being on internet^^ so if you have some time to spare have a look at http://www.crudsader.com/. The novelty of the framework lies in object automatic forms, configuration and the Object query language (which is very simple and uses string instead of object methods). It's missing cache and performance improvement at the moment but I'm working on it. I will gladly appreciate any comments to make it better, or about anything that the framework is missing or where I could have been completely wrong! Regards, Jean-Baptiste Verrey ps: I'm working hard on checking that the examples of the doc are actually working, and to add more content to the docs
[PHP] filter_input and $_POST deep array
Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'login[email]') but it does not work! Regards, Jean-Baptiste Verrey
Re: [PHP] Re: filter_input and $_POST deep array
What do you mean? I don't see how I could use foreach there On 23 September 2011 13:31, Al n...@ridersite.org wrote: On 9/23/2011 5:51 AM, jean-baptiste verrey wrote: Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'**login[email]') but it does not work! Regards, Jean-Baptiste Verrey foreach() in the manual -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: filter_input and $_POST deep array
seems that the only solution is to still use $_POST and use filter_var instead, it could have been better! On 23 September 2011 14:11, jean-baptiste verrey jeanbaptiste.ver...@gmail.com wrote: What do you mean? I don't see how I could use foreach there On 23 September 2011 13:31, Al n...@ridersite.org wrote: On 9/23/2011 5:51 AM, jean-baptiste verrey wrote: Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'**login[email]') but it does not work! Regards, Jean-Baptiste Verrey foreach() in the manual -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: filter_input and $_POST deep array
foreach cannot work in this situation has filter_input does not work recursively and work only on the first level of $_POST (or $_GET) so the best solution seems to be to use filter_var($_POST['var']['var2']); Thanks anyway On 23 September 2011 17:13, Thijs Lensselink d...@lenss.nl wrote: On 09/23/2011 03:17 PM, jean-baptiste verrey wrote: seems that the only solution is to still use $_POST and use filter_var instead, it could have been better! You can foreach the $_Post['login'] array and use filter_input on each iteration to do the filtering. Or maybe the filter_input_array is a better place to look at. The manual is your friend. http://php.net/manual/en/function.filter-input.php Besides that. Calling filter_var two times won't kill you! On 23 September 2011 14:11, jean-baptiste verrey jeanbaptiste.ver...@gmail.com wrote: What do you mean? I don't see how I could use foreach there On 23 September 2011 13:31, Al n...@ridersite.org wrote: On 9/23/2011 5:51 AM, jean-baptiste verrey wrote: Hi, I have using a form that gives me something like $_POST=array( 'login'=array( 'email'='he...@myphp.net', 'password'='123456' ) ) is there a way to use filter_input function to filter the values? I tried filter_input(INPUT_POST,'**login[email]') but it does not work! Regards, Jean-Baptiste Verrey foreach() in the manual -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql adapter and DAL
hi, If you are building your own dal I guess you would have to build your own adapter, simply use mysqli function and wrap them in a class. On 17 September 2011 12:24, shahrzad khorrami shahrzad.khorr...@gmail.comwrote: hi all, I'm looking for a mysql adapter for create my dal.. where can I find a good one? and have you ever written a dal with a mysql adapter? in my dal I want to pass parameters to sql sting, for example like following: $db-query($sql, array($name, $family)) thanks, Shahrzad Khorrami
Re: [PHP] form handling
it's (pretty) easy to send two forms at once with jquery nowadays, you just get all the input of the 2 forms and post them! function submit2Forms(form1DomId,form2DomId){ $datas={}; $(form1DomId).find(':input').each(function(){ if(($(this).attr('name') $(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' $(this).is(':checked'))) $datas[$(this).attr('name')]=$(this).val(); }); $(form2DomId).find(':input').each(function(){ if(($(this).attr('name') $(this).attr('type')!='checkbox') || ($(this).attr('type')=='checkbox' $(this).is(':checked'))) $datas[$(this).attr('name')]=$(this).val(); }); $.post(URL,function(html) { $('body').html(html); }) return false; }); it's just a small example so you can see how you can do it! On 12 August 2011 08:48, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Chris Stinemetz chrisstinem...@gmail.com wrote: I would bet it's the quotes screwing up the js. Can / are you escaping that variable when ajaxing it back? Bastien Koert 905-904-0334 I found a way to make the ajax work with one form. I removed the table and the ajax worked just fine. Aparently you can't embed div containers within a table without affecting the whole table. At least that is what I found out tonight. Please correct me if I am wrong. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Without seeing your code, its hard to figure out what is happening. Post it onto pastebin or something (large code excerpts are very hard to read on this mailing list). Often, running the code through validator.w3.org will find issues that are affecting your layout. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Already Filled Out
if you want to force the browser to not be able to have this behaviour you need the name tag to always change a quick example would be that ?php // keep the name in session $_SESSION['formRandomName']=time(); ? input type=password name=?php echo $_SESSION['formRandomName'];?[password] / 2011/8/4 Bálint Horváth hbal...@gmail.com Hi, Use value=$_POST['user'] or sg like that because: before send value eq null, after if returned -cause of a fail- the inputs remain also set *autocomplete=off* (at form) and if it doesn't work use js to set null values to input boxes (add a name for ur form...) Another way, use Google: javascript turn off autofill be careful: http://www.php.net/manual/en/security.database.sql-injection.php http://php.net/manual/en/security.php *Valentine* On Thu, Aug 4, 2011 at 8:54 AM, James Yerge ja...@nixsecurity.org wrote: On 08/05/2011 12:43 AM, wil prim wrote: Hello, S i created a simple login system, and I am using sessions Everything seems to work fine, however; when I upload my files to my server and type my domain name my index.php page comes up and the form is automatically filled out with a username and password. How do i make it empty when I initially enter the site, and yes I did create a logout.php file that destroys a session. Please help, it is hard to explain this when I cant show it in person. Thanks in advance! Here is the login.php code, i didn't md5() the password yet: ?php if ($_SESSION['user']) { header(Location: error.php); exit(); } include('connect.php'); if ($_POST['login']){ $user=$_POST['user']; $pass=$_POST['pass']; $sql=SELECT * FROM members WHERE username='$_POST[user]' and password='$_POST[pass]'; $result=mysql_query($sql, $con); $count=mysql_num_rows($result); if ($count==1){ $_SESSION['user'] = $user; header('location: home.php'); } else echo p style='color:red'Wrong Username or Password/p; } ? html head title/title link href=style.css rel=stylesheet type=text/css / /head body div id=main div id=menu ul li a href=#Home/a /li li a href=#Topix/a /li li a href=#Mission/a /li /ul /div div id='content' form method='post' action='index.php' Username: br/ input type='text' name='user' maxlength='30'/br/ Password: br/ input type=password name='pass' maxlength='30'/br/ input type=submit value=Log In! name=login/ /form a href=register.html Register? /a /div /body /html Your browser is more than likely filling in the username and password fields for you, automatically. Most modern browsers offer this functionality by default. What you're looking for isn't relative to PHP. Have you tried visiting your page from multiple browsers, to see if you get the same results? You could set the value of the username and password fields in the form to NULL. e.g.; input type='text' name='user' value='' maxlength='30'/ input type=password name='pass' value='' maxlength='30'/ I doubt your visitors are going to encounter the same issue you are, unless they allow their browser or some other 3rd party software to automatically fill in the form values for them. Another method would consist of using JavaScript, once the DOM is ready (all elements rendered), have JavaScript reset the form values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best editor?
NetBeans for PHP is definitely a GREAT choice! (it is now made to work specially for PHP) And if you don't have access to everything on your computer just install a VMWare player and have a virtual server ;-) (ok it would take time but once you have it, you have it) On 3 August 2011 18:07, Leonardo l...@matrix-leo.cz wrote: Dne středa 03 srpna 2011 15:22:44 Matty Sarro napsal(a): Hey everyone, I am a super newbie just beginning to learn PHP. Awhile ago, I had used aptana for dabbling with php and was amazed to find out that it had a built in php interpreter so I could do some minor testing without having to upload everything to a web server, or have a web server locally. Flash forward to now, and it looks like that functionality doesn't exist anymore (at least not by default). So, I'm curious what editors are out there? Are there any out there which will let me test PHP files without having to upload everything every time I edit it? Any help would be greatly appreciated. Thanks! -Matty The best editor for PHP is Zend Studio cca $300 or open source products like Kate(linux), Kwrite(linux), Vim(linux, windows), BlueFish(linux), Emacs(Linux, Windows). I'm using the Bluefish for PHP with (XHTML) and NetBeans for others programming languages. Good look. I'm sorry for my english. -- Leonardo -- Teoretické znalosti dnes už nestačí. Člověk musí překročit jejich hranice a umění se stane neumělým uměním, které vyrústá z nevědomí Daitsu Suzuki ( 1870 - 1966 ) - Feder ajsi romňi, so buter manušňi sar džuvli. Cikánské přísloví -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] vend-bot?
you always receive from paypal information (you should have something in $_POST or $_GET) so you can actually identify who it was, so it would be easy to simply say that if you don't have the information sent then you don't show the page. I don't recall exactly how this principal works but it was something like that. On 3 July 2011 18:32, Kirk Bailey kbai...@howlermonkey.net wrote: OK, I want to send someone back from paypal to a thank you page; this reloads to the actual file they will purchase. BUT, I want to include a magic cookie that will prevent someone else from going to that url at a later time and getting the payload without paying for it. Any thoughts on how to build a secure vendobot? Let's discuss this in this thread. -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] best ways to recruit volunteers for a PHP framework
Hi everybody, I have developed an ORM framework in PHP for the last 2 years and it's becoming a more professional and nice solution so before doing a new complete revamp I am going to look for volunteer developers to do a real good version. But I am wondering what would be the best and clearest way to present the project in order to get some people interested in it ? I was thinking about - showing the previous versions - showing use cases - showing unit testing (I'm doing test driven development) - a short user manual (the project doesn't have any user manual yet!) Thanks in advance!
Re: [PHP] best ways to recruit volunteers for a PHP framework
thanks, I should have said I have the project already in sourceforge so I have an SVN ready, and a outdated website with an outdated user manual and even an outdated dissertation about the reason for the development of the project. On 28 June 2011 21:29, Jay Blanchard jblanch...@pocket.com wrote: [snip] I have developed an ORM framework in PHP for the last 2 years and it's becoming a more professional and nice solution so before doing a new complete revamp I am going to look for volunteer developers to do a real good version. [/snip] https://github.com/
Re: [PHP] what kind of features would you like in php orms?
- defining the mapping schema in an alternate method than using meta data (I HATE them, I would prefer an XML file with a DTD so you could use autocompletion with IDE like NetBeans) - clear keywords in the schema - OQL can do UPDATEs - one and only one configuration file with everything in it (and with why not the schema) - to not forget to KEEP IT SIMPLE, specialised ORM that does everything already exists so there's no point in writing one! that's it for me (at least at the moment) Of course I would suggest to use PHP 5.3 specially for late static binding (and for people that love namespaces) On 17 June 2011 07:42, 李白|字一日 calid...@gmail.com wrote: and how to design such an orm in current state of php language?
Re: [PHP] what kind of features would you like in php orms?
You could simply use like doctrine DBAL or an already existing one made specially for ORM, or you can design one and at the moment make it to use only MySQL PDO is actually good enough to do that, I know that the only thing I had to do in my ORM was to write a special class to translate some queries for MySQL (to be able to use LIMIT for objects instead of rows). On 17 June 2011 12:06, 李白|字一日 calid...@gmail.com wrote: thanks, how about the abstraction of different databases? it seems PDO is still lack of functions of importance. I'm currently trying to design a automated model like django or activeRecord. it should be quiet simple and automated, i have managed to possibly create the whole database only once. but the abstraction of the database and subsequent manipulation seem far more complicated than the previous part i'm currently only support mysql and only support whole query at once. 2011/6/17 jean-baptiste verrey jeanbaptiste.ver...@gmail.com - defining the mapping schema in an alternate method than using meta data (I HATE them, I would prefer an XML file with a DTD so you could use autocompletion with IDE like NetBeans) java's hibernate instead of python's exlir or ruby 's rail style ? mean no ActiveRecord? - clear keywords in the schema - OQL can do UPDATEs - one and only one configuration file with everything in it (and with why not the schema) - to not forget to KEEP IT SIMPLE, specialised ORM that does everything already exists so there's no point in writing one! that's it for me (at least at the moment) Of course I would suggest to use PHP 5.3 specially for late static binding (and for people that love namespaces) On 17 June 2011 07:42, 李白|字一日 calid...@gmail.com wrote: and how to design such an orm in current state of php language?
Re: [PHP] building a key value pair dynamically
with mysql use mysql_fetch_assoc, is that what you are asking for ? On 1 June 2011 16:31, Adam Preece a...@blueyonder.co.uk wrote: hi all, is it possible to dynamically build a key value pair array in php from a database result? if so how? kind regards Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] smart auto download file
it's made in JavaScript, by creating an iframe loading the file, but their downloader might use something like a php file to force download such as ?php $filePath='/var/wwwblablah.zip'; header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename=azipfile.zip'); readfile($filePath); ? On 31 May 2011 18:02, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.comwrote: I want to build a web page for file auto download like cnet.download. A page that tells user Your download will begin in a moment... and after a few seconds download starts. How can I do that by php thanks for any help. -- Ali Asghar Torabi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] smart auto download file
gosh, I should have read before answering for the downloader thing. BUT you actually need javascript if you want to do it. You create an hidden iframe somewhere on your page, you give him the url of your file and pop it is downloaded, and you need simply to use javascript function setInterval to do that after a couple of seconds! On 31 May 2011 20:38, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.comwrote: Hi thanks for your help jean I've used this code before. But I want a little different thing. I need to tell something to the user before starting download. something like Your download will begin in a moment... . So header couldn't help me. If I try to echo anything header doesn't work! On Tue, May 31, 2011 at 10:01 PM, jean-baptiste verrey jeanbaptiste.ver...@gmail.com wrote: it's made in JavaScript, by creating an iframe loading the file, but their downloader might use something like a php file to force download such as ?php $filePath='/var/wwwblablah.zip'; header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename=azipfile.zip'); readfile($filePath); ? On 31 May 2011 18:02, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: I want to build a web page for file auto download like cnet.download. A page that tells user Your download will begin in a moment... and after a few seconds download starts. How can I do that by php thanks for any help. -- Ali Asghar Torabi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ali Asghar Torabi
Re: [PHP] iPhone sadness
I like how people just like to complain about everything^^ But as the debate is raging I had a look over internet and http://www.caliburn.nl/topposting.html gave the best argument ever : we read from *top* to *bottom *so top posting makes you read useless information^^ Don't worry, be PHaPpy! On 30 May 2011 19:01, Lester Caine les...@lsces.co.uk wrote: Ashley Sheridan wrote: And, BTW, this bottom posting has started just two or three years ago when Thunderbird came in place. Erm, bottom posting has been the standard since day 1 until Microsoft came along and changed it with Outlook. Most people who use Windows tend not to change basic settings from their defaults. Exactly ... I've email archives going back to 1992 and ALL of the early stuff is nicely formatted with in-line and bottom posted expansion. I've actually been editing things I would like to keep to put some sense back into the archive - but on the most part just trimming reams of unnecessary repeated sigs where people have not even bothered looking at what they quoted! I've got a nice module on my php client management system that trims stuff automatically for me when I'm uploading old messages. -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Object Query Language optimization
hi folks, I'm writing an Object Query Language which is pretty simple, you do request such as *SELECT e.*,c.firstName * *FROM employee e * *JOIN contact c ON e* *WHERE e.id=*? (queries don't get much more complicated than that, you have multiple alias.fieldName in the select, then multiple joins) I'm trying to find the best way to get all the informations. At the moment I am doing a preg_match that simply verify that the whole syntax is good , but to separate all the information i have to separate the query in sub parts (select, from , join, where) and do a preg_match_all on them. So my questions are : - is there a better way to do this? - about regular expression : (that would directly solve my problem) if you do preg_match('!(([a-z])+)!','abcabc',$matches); echo 'pre';print_r($matches);echo '/pre'; you get only the last letter, is there a way to get all of them ??? (using a regular expression and only preg_match, no preg_match_all) http://www.regular-expressions.info/captureall.html Regards, JB
Re: [PHP] Object Query Language optimization
hi, I often use SQL that is far, far more complex than this. well, this is why my OQL is pretty simple, it does not intend to do any crazy stuff that you can do with SQL (as I can load objects from SQL as well) I had a look at other ORM, and the problem is that some are extremely complicated (Doctrine is a very specialized framework, you can basically do anything you can do with SQL but in OQL) , they don't have OQL, they use active recode like query, or they use a class with chain methods. My problem in itself is not really a problem as it is working, but I just wonder how to optimize it, if I should write some different version and benchmark it, or identify from the beginning that my solution is good enough. Thanks anyway^^ On 21 May 2011 16:54, Mark Kelly p...@wastedtimes.net wrote: Hi. On Saturday 21 May 2011 at 15:56 jean-baptiste verrey wrote: I'm writing an Object Query Language [snip] (queries don't get much more complicated than that, you have multiple alias.fieldName in the select, then multiple joins) I often use SQL that is far, far more complex than this. Anyway, I can't help directly with the code, other than to suggest that you take a look at other projects that do the same thing and see how they do it. There's a starter list at: http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#PHP HTH, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php