Jump to content

ajlisowski

Members
  • Posts

    114
  • Joined

  • Last visited

    Never

Everything posted by ajlisowski

  1. I am having an issue when trying to access my own PHP Soap Service with PHP. Technically I am using Zend_Soap for both, but I do not think this is a zend specific problem, but perhaps it is. Basically, the result I get from the client is null. However if I look at the last response, it contains the expected, correct XML. So the client is failing to convert the xml to a php object (in my test case, a simple string) for use. my wsdl looks like this definitions name="SOAP_Model_soaphandler" targetNamespace="http://website.com/appldev/applications/public/SOAP/index/soap"> <types> <xsd:schema targetNamespace="http://website.com/appldev/applications/public/SOAP/index/soap"/> </types> <portType name="SOAP_Model_soaphandlerPort"> <operation name="test"> <documentation>Returns list of all products in database</documentation> <input message="tns:testIn"/> <output message="tns:testOut"/> </operation> <operation name="test2"> <documentation>Adds new product to database</documentation> <input message="tns:test2In"/> <output message="tns:test2Out"/> </operation> </portType> <binding name="SOAP_Model_soaphandlerBinding" type="tns:SOAP_Model_soaphandlerPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="test"> <soap:operation soapAction="http://website.com/appldev/applications/public/SOAP/index/soap#test"/> <input> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/> </input> <output> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/> </output> </operation> <operation name="test2"> <soap:operation soapAction="http://website.com/appldev/applications/public/SOAP/index/soap#test2"/> <input> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/> </input> <output> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/> </output> </operation> </binding> <service name="SOAP_Model_soaphandlerService"> <port name="SOAP_Model_soaphandlerPort" binding="tns:SOAP_Model_soaphandlerBinding"> <soap:address location="http://website.com/appldev/applications/public/SOAP/index/soap"/> </port> </service> <message name="testIn"/> <message name="testOut"> <part name="return" type="xsd:int"/> </message> <message name="test2In"> <part name="id" type="xsd:int"/> </message> <message name="test2Out"> <part name="return" type="soap-enc:Array"/> </message> </definitions>[/code my response looks like this [code] <env:envelope xmlns:enc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://website.com/appldev/applications/public/SOAP/index/soap" xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"> <ns1:testresponse env:encodingstyle="http://www.w3.org/2003/05/soap-encoding"> <rpc:result>return</rpc:result> <return xsi:type="xsd:int">7</return> </ns1:testresponse> </env:body> </env:envelope> but $result=$client->test(); var_dump($result); outputs NULL. Any ideas?
  2. Ok, so it turns out that even though I was setting the wsdl to not be cached in the client, i wasnt for the server. So the server was using an old WSDL generated from a class without the php comment declarations. I am now successfully getting a proper response back from the server, however when I print out the result, it is empty. $client->getLastRequest() has properly formatted xml, but I cant seem the access the response. var_dump gives a null result. I should be able to figure this part out without too much trouble though.
  3. I am having a number of issues attempting to set up and utilize SOAP in zend. First, when I create my WSDL on my wsdl it returns: However if I add die(""); to the end of my wsdlAction() I properly get the xml WSDL to display. I am not sure why I need to add that, as I have disabled layouts and scripts in the preDisptach for the controller. So, adding die("") I got my WSDL up and running which is awesome. But now contacting it via a client is not working. I am getting a soap fault of code HTTP and string Internal Server Error. Further investigation into the stack trace shows the error occuring in /library/Zend/Soap/Client.php on line 989. This appears to be the code call_user_func(array($client,'SoapClient::__doRequest'),$request,$location,$action,$version) I do not know how to debug any further. I am not sure what is causing it. I am relatively sure my WSDL issue is not related. My WSDL is fine with the die("") so the client is reading it fine. The issue is in performing the request. Any ideas what is happening here?
  4. So, I am able to get the availability via PIVOT on the Time field twice. Once to get any repeating or scheduled unavailability and once to get any cancels. Having both Cancels and whether or not something is scheduled, I know whether or not a user is available for that time. Assignments is another story. I could get the total number of assignments for that time using the same pivot plan. However, I need more info than that. I need to get actual appointment information scheduled for that hour, not just how many. Since Pivot requires an aggregate function to return values I can not return a concatination of data back. I'm guessing ill have to talk to my DBA and get a function created to do a group_concat.
  5. Hi, I have written a system that displays the users availabilityfor the day. Basically there is a user table, an assignment table and an availabilitytable. The system I have works fine for a smaller data set, but I have run into problems when loading more users at once. Basically I am having trouble grabbing their schedule for the day in one query. Users table, for the purposes of this question is user UserID, Name assignment is AssignmentID, UserID, AppointmentID appointment is AppointmentID, AppointmentDate, AppointmentTime availability is AvailabilityID, UserID, Date, Time, Repeating, Cancel Repeating is a bool that repeats on all days that match the same day of the week for that time. Cancel is a bool that says to not execute the repeating availability for that day/time. So if someone has a repeating event scheduled for every monday at 1pm, but they also have a cancel event scheduled for today at 1pm, they will be free today at 1pm. Anyway, I want a query that returns the user information, including a string showing their schedule for every hour of the day. so UserID, Name,8,9,10,11,12,13,14,15,16,17,18,19 where each field 8-19 is a string containing either the user being unavailable for that hour, or a list of the assignments they have for that hour. The only way I can think to do this off the top of my head is to make a join on the availability table and assignment table for every hour. But that seems inefficient and I would assume there is a much better way. Right now I load the user availability and assignments for each user in a seperate queries. But obviously if there's 100+ users Im showing at once, thats 200+ queries for each user. Id much prefer to load in all that info in one query. Any ideas?
  6. Basically I want to write a query that checks to see if data exists in multiple ranges. So lets say I have a numeric field "data". I want to write a query to see if a row exists with data >2 AND data between 2 and 1 AND data less then 1. I want to see if a row exists in all 3 of these ranges. I could do 3 separate queries, or I could do 1 query with two UNIONs but is that any better? Is there any reason to union them over doing 1 query? Is there another option that I am missing?
  7. Wow...yeah thats a lot simpler then what I did. Hah. I feel foolish for not thinking of that, thanks a bunch.
  8. Maybe I asked the question wrong... basically I have a table of opportunities, these can either be sold, lost or open. Opportunity Status Salesman ID 1 Open 120 2 Sold 120 3 Lost 120 I would want a query that would get me the following row as a return Total Opportunities Closed Opportunities Lost Opportunities 3 2 1 So I would need to group by salesman ID and then count the total number of opportunities, the total number of opportunities which are either sold or lost, then the total number of opportunities which are lost. Right now I am doing so with the following query SELECT s.`id`, count(DISTINCT open.`id`)+ count(DISTINCT sold.`id`)+ count(DISTINCT lost.`id`) AS `total` count(DISTINCT sold.`id`)+ count(DISTINCT lost.`id`) AS `closed` count(DISTINCT lost.`id`) AS `lost` FROM `salesman` AS `s` JOIN `opportunities` AS `open` ON (open.`salesman_id`=s.`id` AND (open.`status`!='sold' AND open.`status`!='lost')) JOIN `opportunities` AS `sold` ON (sold.`salesman_id`=s.`id` AND sold.`status`='sold' ) JOIN `opportunities` AS `lost` ON (lost.`salesman_id`=s.`id` AND lost.`status`='lost') GROUP BY s.`id` It works but it seems like a roundabout way of accomplishing what I want. But I can not think of any other way, cause I want to pretty much have a where statement within my count, and the only way i can think of doing that is with a join.
  9. Ah, Im guessing I would have to do a count(distinct blah) and then use joins to get both the sold and the total. Is this the correct method or am I making things way too difficult?
  10. So I need to have a query that grabs some sales figures by salesman. It would need to report back the total opportunities and also how many of those were sold. If I just wanted to get the amount sold I could do the followng SELECT `lret_retailsalesman_id_c`, count(`id`) FROM `lret_retailopportunity` WHERE `status`='sold' But how would I do a query that returns both the amount sold and the total amount in one line?
  11. Yes, if you store the object in the session it should act exactly as how it did before hand. Others have mentioned autoloading but its important to note that if you store an object in a session it either needs to be autoloaded or the class of the object needs to already have been defined by the time session_start() is called. Personally I never store objects in a session. For a user I would just store the ID of the user and have some piece of code run that would recreate the object based on that ID whenever it is needed (or even automatically on every page, but that's the benifit of having a single point of access). OO in php is a bit hard to grasp coming from C++ and the like specifically because of the fact the objects are not carried throughout the session. By this I just meant a function that will take the ID of the object and grab data from the DB and set the various variables within the class.
  12. You would create a session with whatever data you need to recreate the object and then do so, php itself does not store the object. You CAN serialize an object and store it in a session and then deserialize it, but I do not recommend doing so. Usually if it is a lot of information you would store it in a database and then store the primary key in a session and create a function in the class which will reset its objects based on the DB info.
  13. I am in the midst of developing a web application and despite having a decent amount of experience in web development, I never really stopped and gave a ton of thought to memory when it comes to my php scripts. However, with this project I am using zend framework and it is a decent memory hog. So I have some questions... I am monitoring my memory use for a typical call to my site and it appears as though its somewhere around 20MB. This seems like a ton and I am actively looking for ways to decrease it. One thing I noticed is that when I call zend's date class for the first time, my memory usage shoots up 3MB. However it is pretty much untouched for other instances of this class. So if I do echo(memory_get_usage()); echo('<br />'); $this->last_login=Zend_Date::now(); echo(memory_get_usage()); echo('<br />'); $this->last_active=Zend_Date::now(); echo(memory_get_usage()); echo('<br />'); The result is So the jump is with that first call. My question is, if two users are accessing the site at the same time, will they both experience that 3MB memory use? Or will the server have that class in memory so it only uses 3MB once? Basically, if a call to the site uses 20MB of memory, will it be 20MB * the number of users. Or will the server have a lot of the information loaded into memory to subsequent calls so multiple users would use up far less memory then the initial? I would assume the latter is the case based on the fact that reusing zend_date doesn't incur a 3MB hit every time. But without being admin of my server and hvaing tons of folks to test at once, its hard to tell.
  14. Unless habbo has an API to provide external users this information, it is not going to be easily achieved. You would have to create a script which scraped the habbo page and parsed the results for specific information you want. This would also break whenever they made signifigant (or possibly even small) changes to the site you are scraping. Even then, scraping it would be immoral at best and possibly illegal. I googled looking for any API provided by habbo and it does not seem to exist, so scraping would be your only option IMO. And even then, Im not sure you would need javascript. you could scrape completely in PHP and display the results. You COULD use javascript and ajax to display things dynamically to the user, but it isnt remotely necessary based on what youve described.
  15. Actually, the service does accept jsonp! I just had to add jsonp=return function to the end of the call and it works fine! Thanks!
  16. Yeah, Im assuming if it did, places.jsonp would be the correct format. That explains why when I tried changing my request type to jsonp, I did get a response, but it couldnt parse it. Right now my solution is to make a proxy php page which simply routes the request and displays the result. This is working fine, but it brings up a concern. Some APIs have a usage limitation based on IP. If I could send it directly via javascript, the IP would be that of the client. If i use the re-route through my php server, the IP will be that of the server and reach its limit much, much quicker. With the particular service I am using, it DOES have a 5000 query limit per user. But I believe that amount is reached via a unique user id passed with the request and not via IP. So I should be fine there, because I can just send the user ID or generate a random one for a guest and send that.
  17. so then what is the proper way to retrieve data from an external source using javascript?
  18. So, I am making a jquery ajax call to a restful application. The call generates a url of: http://geoapi.fwix.com/places.json?api_key=25645fa7e150&lat=39.8062&lng=-86.1407&range=2 Which if you go to that url you will see it properly generates JSON. However, looking at firebug, the call fails to get a response from the server. my jquery code is as follows: var latitude=$('#location_lat').val(); var longitude=$('#location_long').val(); var range=obj.range; var data='api_key='+obj.fwixAPI; data=data+'&lat='+latitude; data=data+'&lng='+longitude; data=data+'&range='+range; data=data+'&page_size='+10; $.ajax({ type: "GET", url: 'http://geoapi.fwix.com/places.json', data: data, dataType: 'json', success: function(msg){ system_obj.debug(msg); } }); Since the URL generated by the request is properly outputting JSON, I can not figure out why it is failing, any ideas?
  19. I am going to think about your problem some more to see if there is a better way... but SELECT em.name AS morning_shift, ed.name AS day_shift, ee.name AS evening_shift FROM schedule AS s LEFT JOIN employees AS em ON s.morning_shift = em.id LEFT JOIN employees AS ed ON s.day_shift = ed.id LEFT JOIN employees AS ee ON s.evening_shift = ee.id WHERE s.date = '2011-07-28' should work. Basically you want to think of each of your shifts as a foriegn key to another table (the employee). And you have to do a join to get the information from the row that key points to. So you need 3 joins, 1 for each of your keys. You were close, except you were trying to join employee on employee when you should be joining schedule to employee. And you need to give alias's to the joined tables so mysql knows which columns to pull from which table.
  20. Hey guys. Sorry I vanished w/o getting back to your questions. I dove headfirst into development, ignoring this library issue. Probably not the smartest move I actually saw this thread again and was going to reply that the problem is still there. However, it when checking for full <?php tags instead of short tags I noticed that my classes were missing closing php tags. Which made me go 'well maybe my server doesnt support that' and sure enough, that fixed it. So, even though the <?php tag fix wasnt the problem, it led me to think along that path and solve it so thank you very much!
  21. So performance wise there is no harm, but the harm is in maintaining the code. Makes sense to me. As for my second question... I suppose I guess my concern is... does selecting more fields on a complex query matter? Lest say it takes X seconds to run a query returning just the primary key. And you get Y results. Then it takes Z seconds to return the query on the primary key to get all the columns. Your total time is X+(Y*Z) Now it takes X*C seconds to run the query on all the fields where C is a factor derived from the number of fields you have. function(number_of_fields)=C; In theory depending on how big C is, the second method could be signifigantly longer if X is very large. Im assuming C is almost negilable, where the amount of fields returned doesnt have that big of an impact. But I am not sure of that, hence my concern. Im not sure if this question makes any sense...or is a remotely valid concern. But ive tried to present it in a number of ways to get across what I am pondering. If it doesnt make sense or flat out isnt something to worry about then feel free to call me a dummy and send me on my way
  22. So...dumb question. Lets say I have a table that contains an id, username and full_name. And I actually do want all 3 of those columns returned to me. Is there a reason not to use SELECT * there? Is SELECT `id`,`username`,`full_name` better then SELECT * in that situation? Ive been working with Zend_Framework a lot lately and Ive been basing my code on the way I have seen some MVC driven CRM systems work- where if they have a user object, whenever they retrieve that object they grab all the related data from the db. Obviously if I am running a search where I only need to return the id it would be silly to do a SELECT *. But when I am actually loading in the object, and I need every field in the table, is there a downside to SELECT *? And to take it a step further, if my process is to first search for the users. Then once I have a result of the IDs for those users, to create user objects and retrieve the data into them, does it make sense to grab all the fields with the search query and initiate the user objects via that data rather then retrieving them via id? Basically $Q="SELECT `id` FROM `user`"; $results=$db->query($Q); foreach($results AS $result) { $newuser=new user($result->id); } VS $Q="SELECT * FROM `user`"; $results=$db->query($Q); foreach($results AS $result) { $newuser=new user(); $newuser->loadByObject($result); } In the top example you have a SELECT `id` that is ran across all results. Then X amount of SELECT * ran against a primary key. In the bottom example you have a SELECT * ran against all results and no followup queries. Which way is the better way to handle it?
  23. Well the problem is that i do ordering by and searching by that column. So I need to work it in the query itself. Otherwise when you order by that column, you will only order by the name and not the label. Same with searching. I believe I have figured it out though. SELECT `id`, `name` AS `labelname` FROM `table` UNION ALL SELECT `id`, `label` AS `labelname` FROM `table` WHERE `label`!=''; This way when I order BY `labelname` it will work properly. My filter query has to be different for each UNION portion, but thats not too big of a deal. Ive tested this and it appears to be working, but I have to explore the results fully to make sure. Thanks for your help though. If it wasnt for some specific requirements, the php solution would work fine and likely be quite a bit quicker.
  24. I have a quick mysql question and for some reason my brain cant figure it out right now. basically I have a table. Id Name Label 1 Product 1 [/td] [td]1 Product 2 Label 2 I want to write a query that pulls the id and the name if the label is empty but pulls two rows, one id and name, one id and label if the label is not empty. So my result would be ID Name 1 Product 1 2 Product 2 2 Label 2 Any ideas how I should go about this? I feel like it shouldnt be too tough, but Im blanking.
  25. Im confused as to why this is needed, unless this is a weird way of doing some caching. Perhaps if you can explain why you want this to occur I can get a good idea of what you need to do to accomplish it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.