RE: [PHP] database hell
> -Original Message- > From: Nick Edwards [mailto:nick.z.edwa...@gmail.com] > Sent: 12 July 2012 12:30 > To: php-general@lists.php.net > Subject: [PHP] database hell > > Hi > > We have a program that manages users, throughout all database calls > > created as: > $connect = mysql_connect($db_host--other variables); > mysql_query("Delete from clients where id=$User"); > > All this works good, but, we need, in the delete function to delete from > another database > > $connmy=mysql_connect("host","user","pass"); > mysql_select_db("vsq",$connmy); > mysql_query("DELETE from userprefs where > clientr='$User'"); > $mysql_close($connmy); this fails, unless we use a mysql_close prior to it, > and then reconnect to original database after we run this delete, how can we > get around this without closing and reopening? > We have a perl script doing similar for manual runs, and it works well > knowing that $connmy is not $connect, I'm sure there is a simple way to tell > php but I'm darned if I can see it. > > Thanks > Niki > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Just create a new resource/connection to MySQL and pass the identifier into mysql_query(). You'll also want to use mysql_real_escape_string() by the looks of it to attempt to stop SQL injection. Something like this will do it: $db1 = mysql_connect($host,$user,$pass); $db2 = mysql_connect($host,$user,$pass); mysql_select_db('db1',$db1); mysql_select_db('db2',$db2); // do your queries with $DB1 $result = mysql_query("delete from userprefs where clientr=".mysql_real_escape_string($user,$db1)."", $db1); // do your queries again with $DB1 mysql_close($db1);//close db1 mysql_close($db2);//close db2 Cheers Adam. = This email is intended solely for the recipient and is confidential and not for third party unauthorised distribution. If an addressing or transmission error has misdirected this email, please notify the author by replying to this email or notifying the system manager (online.secur...@hl.co.uk). If you are not the intended recipient you must not disclose, distribute, copy, print or rely on this email. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of Hargreaves Lansdown. In addition, staff are not authorised to enter into any contract through email and therefore nothing contained herein should be construed as such. Hargreaves Lansdown makes no warranty as to the accuracy or completeness of any information contained within this email. In particular, Hargreaves Lansdown does not accept responsibility for any changes made to this email after it was sent. Hargreaves Lansdown Asset Management Limited (Company Registration No 1896481), Hargreaves Lansdown Fund Managers Limited (No 2707155), Hargreaves Lansdown Pensions Direct Limited (No 3509545) and Hargreaves Lansdown Stockbrokers Limited (No 1822701) are authorised and regulated by the Financial Services Authority and registered in England and Wales. The registered office for all companies is One College Square South, Anchor Road, Bristol, BS1 5HL. Telephone: 0117 988 9880 __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __
RE: [PHP] Entry point of an MVC framework
> -Original Message- > From: Simon Dániel [mailto:simondan...@gmail.com] > Sent: 12 July 2012 21:21 > To: php-general@lists.php.net > Subject: [PHP] Entry point of an MVC framework > > Hi, > > I have started to develop a simple MVC framework. > > I have a base controller class which is abstract and all of the controllers > are > inherited from that. Every controller contains actions represented by > methods. (E. g. there is a controller for managing product items in a > webshop, and there are seperate actions for create, modify, remove, etc.) > There is also a default action (usually an index page), which is used when > nothing is requested. > > But what is the best way to invoke an action? I can't do it with the > baseController constructor, becouse parent class can't see inherited classes. > And I can't do it with the constructor of the inherited class, becouse this > way I > would overwrite the parent constructor. And as far as I know, it is not a good > practice to call a method outside of the class, becouse the concept of > operation of the class should be hidden from the other parts of the > application. > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Hi Simon, You'll probably want to look at Bootstrapping your framework too. Ideally the bootstrap will include (or have an autoload function) to load your classes - controllers/models/views, and it'll also deal with routing so deciding which controller and action to call based on the URL, this usually involves doing an explode() on the $_SERVER['QUERY_STRING'], and using Apache's mod_rewrite to forward all requests to your bootstrap (often named index.php) Building frameworks and going through the motions are a great way to build up experience and play with areas of the language you might not normally use, you might want to get inventive with the Reflection class to check actions or controllers exist and then forward the user to a 404 page later on. Cheers Adam. = This email is intended solely for the recipient and is confidential and not for third party unauthorised distribution. If an addressing or transmission error has misdirected this email, please notify the author by replying to this email or notifying the system manager (online.secur...@hl.co.uk). If you are not the intended recipient you must not disclose, distribute, copy, print or rely on this email. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of Hargreaves Lansdown. In addition, staff are not authorised to enter into any contract through email and therefore nothing contained herein should be construed as such. Hargreaves Lansdown makes no warranty as to the accuracy or completeness of any information contained within this email. In particular, Hargreaves Lansdown does not accept responsibility for any changes made to this email after it was sent. Hargreaves Lansdown Asset Management Limited (Company Registration No 1896481), Hargreaves Lansdown Fund Managers Limited (No 2707155), Hargreaves Lansdown Pensions Direct Limited (No 3509545) and Hargreaves Lansdown Stockbrokers Limited (No 1822701) are authorised and regulated by the Financial Services Authority and registered in England and Wales. The registered office for all companies is One College Square South, Anchor Road, Bristol, BS1 5HL. Telephone: 0117 988 9880 __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __
RE: [PHP] What do you call the end-user?
> -Original Message- > From: Tedd Sperling [mailto:t...@sperling.com] > Sent: 19 July 2012 18:27 > To: php-general@lists.php.net General > Subject: [PHP] What do you call the end-user? > > What do you call the people who ultimately use your code? > > I call them the "end-user", but others have stated other terms, such as > "customer" or "user". > > Cheers, > > tedd > > > t...@sperling.com > http://sperling.com I suppose if you're working in Agile, you could also call them Stakeholders or the Product Owner. Personally if I'm feeling a bit cheeky I'll go with "Muggle" - (thanks to J K Rowling!) - people just don't appreciate the magic involved behind the scenes in usability, infrastructure, application logic etc. Thanks Adam. = This email is intended solely for the recipient and is confidential and not for third party unauthorised distribution. If an addressing or transmission error has misdirected this email, please notify the author by replying to this email or notifying the system manager (online.secur...@hl.co.uk). If you are not the intended recipient you must not disclose, distribute, copy, print or rely on this email. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of Hargreaves Lansdown. In addition, staff are not authorised to enter into any contract through email and therefore nothing contained herein should be construed as such. Hargreaves Lansdown makes no warranty as to the accuracy or completeness of any information contained within this email. In particular, Hargreaves Lansdown does not accept responsibility for any changes made to this email after it was sent. Hargreaves Lansdown Asset Management Limited (Company Registration No 1896481), Hargreaves Lansdown Fund Managers Limited (No 2707155), Hargreaves Lansdown Pensions Direct Limited (No 3509545) and Hargreaves Lansdown Stockbrokers Limited (No 1822701) are authorised and regulated by the Financial Services Authority and registered in England and Wales. The registered office for all companies is One College Square South, Anchor Road, Bristol, BS1 5HL. Telephone: 0117 988 9880 __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __
Re: [PHP] Compiler for the PHP code
Checkout HipHop by the Facebook guys, it turns PHP into C code and compiles down to binary. ...although I don't think it's for the faint hearted. Have you tried other optimisation techniques first - eg Caching, and Profiling?? If this is a production environment you might wanna think about increasing resources or introducing a load balancer (in the case of PHP based websites) Cheers Ads. Sent from my BlackBerry® wireless device -Original Message- From: Camille Hodoul Date: Tue, 19 Mar 2013 09:52:14 To: Kevin Peterson Cc: Subject: Re: [PHP] Compiler for the PHP code Googling "compile php code" gave me this : http://stackoverflow.com/questions/1408417/can-you-compile-php-code It looks like you have some options but I haven't tried any yet, so I can't help you with the installation 2013/3/19 Kevin Peterson > My webcode written in PHP and it is running in the interpreted way. My > problem is it is not giving the desired performance so want to try the > compiler if any. > Please suggest if we have any compiler option available for the PHP code > and more important is this new option. > > -- Camille Hodoul http://camille-hodoul.com/
[PHP] COM - Assigning to method.
Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = "Test account" .Fields(BANK_fld_ACCOUNT_NO) = "12345" .Fields(BANK_fld_BANK) = "Bank of the Nation" .Fields(BANK_fld_BRANCH_NAME) = "State Street Branch" End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API->Init($SerialNo, $Login, '', 1, '', 1); $API->SignOutOnTerminate = True; $Record = new COM("Data.Record"); $Record->Init($API->SessionContext); $Record->Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record->Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = &$Record->Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] COM - Assigning to method.
Richard - I've tried that I get an error about it not being defined as property of the object. Andrew - do you mean try using the method Richard has shown? Cheers Adam. On 13 July 2013 17:11, Richard Quadling wrote: > > > > On 13 July 2013 01:24, Andrew Ballard wrote: >> >> On Jul 12, 2013 4:53 AM, "Adam Nicholls" wrote: >> > >> > Hi Guys/Gals, >> > >> > I'm doing some integration work with a COM API and according to their >> > documentation to save data in the API, you have to assign to the >> > method. >> > >> > This is their example in Visual Basic: >> > >> > >> >> - >> > Set oBank = New CBank >> > oBank.Init Application.SessionContext >> > With oBank >> > .Fields(BANK_fld_ACCOUNT_NAME) = "Test account" >> > .Fields(BANK_fld_ACCOUNT_NO) = "12345" >> > .Fields(BANK_fld_BANK) = "Bank of the Nation" >> > .Fields(BANK_fld_BRANCH_NAME) = "State Street Branch" >> > End With >> > oBank.Save >> > >> >> - >> > >> > Obviously in PHP is isn't possible to assign to a method in this way >> > (thats what parameters are for!) So I'm at a bit of a loose end. I'm >> > wondering if anyone else has come across this? Or am I missing >> > something obvious in PHP's implementation of the COM that allows me to >> > work around this? >> > >> > My PHP Code is looks like this: >> > >> >> - >> > $API = new COM('API7.API'); >> > $API->Init($SerialNo, $Login, '', 1, '', 1); >> > $API->SignOutOnTerminate = True; >> > >> > $Record = new COM("Data.Record"); >> > $Record->Init($API->SessionContext); >> > >> > $Record->Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work >> > >> >> - >> > >> > I've also tried (below) but the API says wrong number of parameters >> > $Record->Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); >> > >> > I've also tried something crazy like this (below) but that overwrites >> > the $Record object. >> > $_R = &$Record->Fields('BANK_fld_ACCOUNT_NAME'); >> > $_R = 'Test Account'; >> > >> > >> > Any ideas? Is it possible? >> > >> > >> > Many Thanks >> > Adam Nicholls >> > >> >> That example isn't assigning values to method return value. Fields is a >> collection of ADO Field objects. The default property of a Field object is >> its Value property, so the shorthand is simply assigning the values of the >> variables to the value of each field in a record within a Recordset. >> >> Andrew > > > So .. > > $oBank->BANK_fld_ACCOUNT_NAME = "Test account"; > > sort of thing. > > -- > Richard Quadling > Twitter : @RQuadling -- Adam Nicholls -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] COM - Assigning to method.
Hi Andrew Thanks for this. But I'm still getting errors. I think I need to explain a bit more. Unfortunately there isn't a PHP API for this application I'm trying to interact with, my goal really is to be able to expose the COM functionality over a web-service such as SOAP so I can use it in a CMS. The application I'm trying to integrate with is Blackbuad's Raiser's Edge - API documentation here: https://www.blackbaud.com/files/support/guides/re7ent/api.pdf I think part of the problem is that the field names are also represented by an integer. So to get data out I would do: $oBank->Fields(22); // which maps to BANK_fld_BRANCH_NAME. When I do: $oBank->22 = 'blah blah'; I get an error because a property can't be numeric, it has to start as alpha character. If I use: $oBank->BANK_fld_BRANCH_NAME = 'blah blah blah'; I get the following error: Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `BANK_fld_BRANCH_NAME': Unknown name. I've also tried using your Value property returned by Fields(): $oBank->Fields(22)->Value = 'Blah Blah blah blah'; Which I then get: PHP Warning: Creating default object from empty value in [C:\Users] Fatal error: Call to undefined method variant::Save() Soo seems nearly impossible to implement a safe way to write to the COM API. At the moment, I'm still in the scoping/prototype stage of my project, so I'm beginning to think that using this COM API for this project is a no-go, which is unfortunate. I'm also guessing even if we did implement this API, exposing it as a Web Service is going to be tricky for performance sake (given that I've read that COM doesn't multithread very well??) Many Thanks Adam. On 14 July 2013 22:16, Andrew Ballard wrote: > On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls wrote: >> >> Richard - I've tried that I get an error about it not being defined as >> property of the object. >> >> Andrew - do you mean try using the method Richard has shown? >> >> Cheers >> Adam. >> >> On 13 July 2013 17:11, Richard Quadling wrote: >> > >> > >> > >> > On 13 July 2013 01:24, Andrew Ballard wrote: >> >> >> >> On Jul 12, 2013 4:53 AM, "Adam Nicholls" wrote: >> >> > >> >> > Hi Guys/Gals, >> >> > >> >> > I'm doing some integration work with a COM API and according to their >> >> > documentation to save data in the API, you have to assign to the >> >> > method. >> >> > >> >> > This is their example in Visual Basic: >> >> > >> >> > >> >> >> >> - >> >> > Set oBank = New CBank >> >> > oBank.Init Application.SessionContext >> >> > With oBank >> >> > .Fields(BANK_fld_ACCOUNT_NAME) = "Test account" >> >> > .Fields(BANK_fld_ACCOUNT_NO) = "12345" >> >> > .Fields(BANK_fld_BANK) = "Bank of the Nation" >> >> > .Fields(BANK_fld_BRANCH_NAME) = "State Street Branch" >> >> > End With >> >> > oBank.Save >> >> > >> >> >> >> - >> >> > >> >> > Obviously in PHP is isn't possible to assign to a method in this way >> >> > (thats what parameters are for!) So I'm at a bit of a loose end. I'm >> >> > wondering if anyone else has come across this? Or am I missing >> >> > something obvious in PHP's implementation of the COM that allows me to >> >> > work around this? >> >> > >> >> > My PHP Code is looks like this: >> >> > >> >> >> >> - >> >> > $API = new COM('API7.API'); >> >> > $API->Init($SerialNo, $Login, '', 1, '', 1); >> >> > $API->SignOutOnTerminate = True; >> >> > >> >> > $Record = new COM("Data.Record"); >> >> > $Record->Init($API->SessionContext); >> >> > >> >> > $Record->Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work >> >> > >> >> >> >> ---