Daily Archives

Articles indexed Friday April 16 2010

Page 15/120 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • select SUM in Cake

    - by SpawnCxy
    When I tried using follow code to get the sum of the column named Serviceinfo.services $conditions = array('fields'=>array('SUM(Serviceinfo.services) as servicecount'),'conditions'=>array('time_id BETWEEN ? AND ?'=>array($startid,$endtid))); $services = $this->Serviceinfo->find('all',$conditions); I had to fetch the sum data with services[0][0]['servicecount'] which seems a little weird.And What I expect is services['Serviceinfo']['servicecount'],or more simple one.Then how can I fix this?Thanks in advance!

    Read the article

  • In Ruby, is there a better way of selecting a constant (or avoiding the constant altogether) based o

    - by Vertis
    Not sure the title fully describes the problem/question I'm trying to ask, sorry. One of my fellow developers has created classes as such: class Widget attr_accessor :model_type ... end and: class ModelType MODEL1 = "model1" MODEL2 = "model2" MODEL3 = "model3" end Now he wants me to convert a retrieved string "MODEL1" to the constant. So that when he is referencing that model elsewhere he can use ModelType::MODEL1. Obviously I've got to convert from the string I'm being given with something like the following: case model_type when 'MODEL1' @model_type = ModelType::MODEL1 ... end I feel like this is clunky, so I'd like to know if there is a better DRYer way of providing this kind of functionality.

    Read the article

  • Middleware with generic communication media layer

    - by Tom
    Greetings all, I'm trying to implement middleware (driver) for an embedded device with generic communication media layer. Not sure what is the best way to do it so I'm seeking an advice from more experienced stackoverflow users:). Basically we've got devices around the country communicating with our servers (or a pda/laptop in used in field). Usual form of communication is over TCP/IP, but could be also using usb, RF dongle, IR, etc. The plan is to have object corresponding with each of these devices, handling the proprietary protocol on one side and requests/responses from other internal systems on the other. The thing is how create something generic in between the media and the handling objects. I had a play around with the TCP dispatcher using boost.asio but trying to create something generic seems like a nightmare :). Anybody tried to do something like that? What is the best way how to do it? Example: Device connects to our Linux server. New middleware instance is created (on the server) which announces itself to one of the running services (details are not important). The service is responsible for making sure that device's time is synchronized. So it asks the middleware what is the device's time, driver translates it to device language (protocol) and sends the message, device responses and driver again translates it for the service. This might seem as a bit overkill for such a simple request but imagine there are more complex requests which the driver must translate, also there are several versions of the device which use different protocol, etc. but would use the same time sync service. The goal is to abstract the devices through the drivers to be able to use the same service to communicate with them. Another example: we find out that the remote communications with the device are down. So we send somebody out with PDA, he connects to the device using USB cable. Starts up the application which has the same functionality as the timesync service. Again middleware instance is created (on the PDA) to translate communication between application and the device this time only using USB/serial media not TCP/IP as in previous example. I hope it makes more sense now :) Cheers, Tom

    Read the article

  • Appending an existing XML file with c#

    - by Farstucker
    I have an existing XML file that I would like to append without changing the format. Existing File looks like this: <Clients> <User username="farstucker"> <UserID>1</UserID> <DOB /> <FirstName>Steve</FirstName> <LastName>Lawrence</LastName> <Location>NYC</Location> </User> </Clients> How can I add another user using this format? My existing code is: string fileLocation = "clients.xml"; XmlTextWriter writer; if (!File.Exists(fileLocation)) { writer = new XmlTextWriter(fileLocation, null); writer.WriteStartDocument(); // Write the Root Element writer.WriteStartElement("Clients"); // End Element and Close writer.WriteEndElement(); writer.Close(); } // Append new data here Ive thought about using XmlDocument Fragment to append the data but Im not certain if I can maintain the existing format ( and empty tags ) without messing up the file. Any advice you could give is much appreciated. EDIT Ive changed the code to read the original XML but the file keeps getting overwritten.

    Read the article

  • Django ForeignKey created empty?

    - by Scott Willman
    This seems very basic and I must be missing something, but here goes anyways... With two models like so: class School(models.Model): name = models.CharField("Official School Name", max_length=128) address = models.TextField("Address of the School", max_length=256) mascot = models.CharField("Name of the School Mascot", max_length=128) class StudentProfile(models.Model): name = models.CharField(max_length=128) school = models.ForeignKey(School) If the student gets created before the school, how do I give 'school' a default empty value? Is it blank or null or what? Thanks!

    Read the article

  • Combining multiple content types into a single search result with Drupal 6 and Views 2

    - by Chaulky
    Hi all, I need to create a somewhat advanced search functionality for my Drupal 6 site. I have a one-to-many relationship between two content types and need to search them, respecting that relationship. To make things more clear... I have content types TypeX and TypeY. TypeY has a node reference CCK field that relates it to a single node of TypeX. So, many nodes of TypeY reference the same node of TypeX. I want to use Views 2 to create a search page for these nodes. I want each search result to be a node of TypeX, along with all the nodes of TypeY that reference it. I know I could just theme the individual results and use a view to add the nodes of TypeY to the single node of TypeX... but that won't allow users to actually search TypeY... it would only search TypeX and merely display some nodes of TypeY along with it. Is there anyway to get the search to account for content in nodes of both content types, but merge the TypeY results into the "parent" node of TypeX? In database terms, it seems like I need to do a join, then filter by the search terms. But I can't figure out how to do this in Views. Thanks for any help i can get!!!

    Read the article

  • Why did MAC-Adress Cloning Fix My Router?

    - by FranticPedantic
    I have a Belkin router, and about a year ago, I suddenly lost my internet connectivity from Comcast. The internet worked fine when I plugged it right into my laptop, so I just ignored it. When I moved to another apartmnet I eventually took the dive and called tech support. The tech told me to clone my MAC address which completely fixed the issue. Now I know what a MAC address is and I've read what MAC cloning is. What has bothered me since is that I don't see how this fixed the issue. As I have understood MAC address cloning, it has the router pretend it has the same MAC address as my computer. Here is why I don't understand why this fixes my issue: I have used several different computers with this router. Cloning the MAC address fixed it for ALL of my computers. The laptop I first used with my ISP was not the one that I eventually had connected when I cloned the address. Furthermore, I didn't have any problems for quite some time after I stopped using the first computer. It wasn't like the internet suddenly stopped working when I changed which laptop I was using Now it occurred to me that maybe there was some sort of expiration? Except... Which MAC address did it clone? It was just an option in the router administration page. Did it just pick whichever computer was connected to it? If my ISP still wanted the MAC of my first computer, how did some other computer's fix it? As mentioned earlier, why did this problem seemingly stem from nowhere? Anyway, I don't have any current problems so this is more just out of general curiosity. If anybody can explain it, it would be appreciated!

    Read the article

  • Exclusive Content and Design With SEM For Your Profits!

    You have surely come across many web design and SEO companies who promise to take you to pinnacles of glory in Internet Marketing, achieving immense success in popularity and wealth. All of them offer to increase website traffic so that your business thrives and increases by leaps and bounds!

    Read the article

  • Domain-Driven-Design question

    - by Michael
    Hello everyone, I have a question about DDD. I'm building a application to learn DDD and I have a question about layering. I have an application that works like this: UI layer calls = Application Layer - Domain Layer - Database Here is a small example of how the code looks: //****************UI LAYER************************ //Uses Ioc to get the service from the factory. //This factory would be in the MyApp.Infrastructure.dll IImplementationFactory factory = new ImplementationFactory(); //Interface and implementation for Shopping Cart service would be in MyApp.ApplicationLayer.dll IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>(); //This is the UI layer, //Calling into Application Layer //to get the shopping cart for a user. //Interface for IShoppingCart would be in MyApp.ApplicationLayer.dll //and implementation for IShoppingCart would be in MyApp.Model. IShoppingCart shoppingCart = service.GetShoppingCartByUserName(userName); //Show shopping cart information. //For example, items bought, price, taxes..etc ... //Pressed Purchase button, so even for when //button is pressed. //Uses Ioc to get the service from the factory again. IImplementationFactory factory = new ImplementationFactory(); IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>(); service.Purchase(shoppingCart); //**********************Application Layer********************** public class ShoppingCartService : IShoppingCartService { public IShoppingCart GetShoppingCartByUserName(string userName) { //Uses Ioc to get the service from the factory. //This factory would be in the MyApp.Infrastructure.dll IImplementationFactory factory = new ImplementationFactory(); //Interface for repository would be in MyApp.Infrastructure.dll //but implementation would by in MyApp.Model.dll IShoppingCartRepository repository = factory.GetImplementationFactory<IShoppingCartRepository>(); IShoppingCart shoppingCart = repository.GetShoppingCartByUserName(username); //Do shopping cart logic like calculating taxes and stuff //I would put these in services but not sure? ... return shoppingCart; } public void Purchase(IShoppingCart shoppingCart) { //Do Purchase logic and calling out to repository ... } } I've seem to put most of my business rules in services rather than the models and I'm not sure if this is correct? Also, i'm not completely sure if I have the laying correct? Do I have the right pieces in the correct place? Also should my models leave my domain model? In general I'm I doing this correct according DDD? Thanks!

    Read the article

  • jQuery Ajax posting Arrays instead of simple data

    - by Ignacio
    Hey, I've tried to update jQuery to its latest version on a system I'm working and I'm having this issue: I have a file that posts data to a .php: $.post( 'ajax_Save.php', { id: [$('#service_id').val()], number: [$('#number').val()] }, function(data){ ... }); On ajax_Save.php var_dump($_POST) gives: array(26) { ["id"]=> array(1) { [0]=> string(5) "18204" } ["number"]=> array(1) { [0]=> string(5) "18250" }... With jQuery version 1.2.2 the result is: array(26) { ["id"]=> string(5) "18204" ["order_number"]=> string(5) "18250" Which is OK. Any clues? Thx

    Read the article

  • php curly braces into array

    - by David
    Hi, I would like to check a opened .txt file for braces that open and close like below: file { nextopen { //content } } no this is not my own language or anything, but I want to get say the nextopen function and all the contents inside the brackets, and all the stuff from inside the file function and add it to an array if you know what i mean. so all the content inside the braces will be in an array. if you know how to do this please reply.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >