Search Results

Search found 129 results on 6 pages for 'fayer'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • singleton vs factory?

    - by fayer
    i've got 3 Log classes that all implements iLog interface: DatabaseLog FileLog ScreenLog there can only be one instance of them. initially i though of using single pattern for each class but then i thought why not use a factory for instantiation instead, cause then i wont have to create single pattern for each one of them and for all future Log classes. and maybe someone would want them as multiple objects in the future. so my questions is: should i use factory or singleton pattern here?

    Read the article

  • help with xml parsing using php

    - by fayer
    i've got following example xml: <entity id="1"> <name>computer</name> <type>category</type> <entities> <entity id="2"> <name>mac</name> <type>category</type> </entity> <entity id="3"> <name>linux</name> <type>category</type> <entities> <entity id="4"> <name>ubuntu</name> <type>category</type> </entity> <entity id="5"> <name>redhat</name> <type>category</type> <entities> <entity id="6"> <name>server</name> <type>category</type> </entity> <entity id="7"> <name>desktop</name> <type>category</type> </entity> </entities> </entity> </entities> </entity> </entities> </entity> if i've got an id, lets say 5. is it possible to retrieve the following: the name of the entity with the id=5 (redhat) ALL the child entities and their name and id (server/6 and desktop/7) all the parent entities and their name and id (computer/1, mac/2 and linux/3) im a noob on parsing xml. is this accomplished by xpath only or xquery/xpath? i would appreciate if someone could give me some example code to do this with simplexml. thanks!

    Read the article

  • helper functions as static functions or procedural functions?

    - by fayer
    i wonder if one should create a helper function in a class as a static function or just have it declared as a procedural function? i tend to think that a static helper function is the right way to go cause then i can see what kind of helper function it is eg. Database::connect(), File::create(). what is best practice?

    Read the article

  • should/could i use ruby-on-rails 3 for my next project?

    - by fayer
    im new to ruby and ruby on rails. im on a new project and would really like to code in ruby. of course u have to use a framework like RoR for web development. so my question is if i should/could use ruby-on-rails 3 for this new project that i will start with in 2-3 weeks from now. are there tutorials for it? is it stable enough? well tested? cause one thing when entering something totally new, you need tutorials and books that teach you how to use it. i guess there arent a lot of sources for this information so maybe its better for me to use the latest stable version? what do you think? thanks

    Read the article

  • get parent elements in xml with simplexml in php?

    - by fayer
    with $element->children() i cant get all the child elements of current element. but how can i get all the parent elements for current element with simplexml? lets say it looks like this: <entity id=1> <name>apple</name> <entities> <entity id=2> <name>mac</name> <entities> <entity id=3> <name>safari</name> </entity> </entities> </entity> </entities> </entity> if my current $element is id=3, i want to get the mac and apple entity ids. is this possible with simplexml cause i cant find any function allowing me to do this?

    Read the article

  • how to use web api with javascript/php?

    - by fayer
    geonames.org got a web api you can use to get all the hierarchy for a city. you just enter the id and you will get the data back in xml. http://ws.geonames.org/hierarchy?geonameId=2657896 i wonder how you fetch the url with php and javascript, and which one should i use. cause the id's are in the mysql database. i will get them with php. should i use file_get_contents, curl or fopen? and what function in javascript? jquery $.post? heard that it can only access localhost. would be great with some guidance here and even better with some code examples. thanks!

    Read the article

  • bundles in java?

    - by fayer
    in symfony 2.0 and django there are bundles that contain everything for a feature (html, css, js, img, php/python). so if you want to delete one feature, you basically just delete that bundle and unregister it from "main". are there java frameworks for this too? or is it different in java cause java is a compiling language. thanks

    Read the article

  • how to store xml structure in a persistence layer?

    - by fayer
    i wonder how i could store a xml structure in a persistence layer. cause the relational data looks like: <entity id="1000070"> <name>apple</name> <entities> <entity id="7002870"> <name>mac</name> <entities> <entity id="7002907"> <name>leopard</name> <entities> <entity id="7024080"> <name>safari</name> </entity> <entity id="7024701"> <name>finder</name> </entity> </entities> </entity> </entities> </entity> <entity id="7024080"> <name>iphone</name> <entities> <entity id="7024080"> <name>3g</name> </entity> <entity id="7024701"> <name>3gs</name> </entity> </entities> </entity> <entity id="7024080"> <name>ipad</name> </entity> </entities> </entity> as you can see, it has no static structure but a dynamical one. mac got 2 descendant levels while iphone got 1 and ipad got 0. i wonder how i could store this data the best way? what are my options. cause it seems impossible to store it in a mysql database due to this dynamical structure. is the only way to store it as a xml file then? is the speed of getting information (xpath/xquery/simplexml) from a xml file worse or greater than from mysql? what are the pros and cons? do i have other options? is storing information in xml files, suited for a lot of users accessing it at the same time? would be great with feedbacks!! thanks!

    Read the article

  • DRY programming dilemma

    - by fayer
    the situation is like this: im creating a Logger class that can write to a file but the write_to_file() function is in a helper class as a static function. i could call that function but then the Log class would be dependent to the helper class. isn't dependency bad? but if i can let it use a helper function then what is the point of having helper functions? what should one prioritize here: using helper functions and have to include this helper class everywhere (but the other 99 methods wont be useful) or just copy and paste into the Log class (but then if i have done this 100 times and then make a change i have to change in 100 places). share your thoughts and experience!

    Read the article

  • how to fetch a url with javascript/jquery?

    - by fayer
    i need to fetch a url with javascript/jquery and not php. i've read that you could do that if you got a php proxy, but that means that it is still going through php. cause then it's still the ip of the server that is fetching it. could one fetch the url entirely with only front-end, and thus fetch it with the client's ip?

    Read the article

  • speed up a sql query to mysql?

    - by fayer
    in my mysql database i've got the geonames database, containing all countries, states and cities. i am using this to create a cascading menu so the user could select where he is from: country - state - county - city. but the main problem is that the query will search through all the 7 millions rows in that table each time i want to get the list of children rows, and that is taking a while 10-15 seconds. i wonder how i could speed this up: caching? table views? reorganizing table structure somehow? and most important, how do i do these things? are there good tutorials you could link to me? i appreciate all help and feedback discussing smart ways of handling this issue!

    Read the article

  • help with xpath selecting

    - by fayer
    i've got an id attribute value for an element. i want to select only its children (not all descendants). i used $childElements = $xml-xpath('//entity[@id=212323]'); print_r($childElements); but that would select ALL descendants and print them out. i just want to select the 1 generation children. how could i do that? <entity id=212323> <this>asd</this> <this>asd</this> <this>asd</this> <this> <notThis>asd</notThis> <notThis>asd</notThis> <notThis>asd</notThis> </this> </entity>

    Read the article

  • how to update rubygems in ubuntu 10.4?

    - by fayer
    when i run "gem -v" i get 1.3.5 i want to upgrade that version cause the bundler gem has to run on a higher version. i have run "apt-get install rubygems" but the version when typing "gem -v" is still 1.3.5. i cant use "gem update --system" on ubuntu, it tells me to update gem using apt-get. please help

    Read the article

  • MVC: models interacts with the view?

    - by fayer
    i know that everything is going through the controller. but i often read articles that says something like this: user interacts with the view controller asks the model to change its state model notifies the view when its sate has changed i dont get the 3rd one. why saying that the model notifies the view, when it actually is notifying the controller and the controller is notifying the view?

    Read the article

  • using sfDoctrineGuardPlugin for regular member login?

    - by fayer
    i want to create users for my webapplication. im using symfony. i wonder if i should do that with sfDoctrineGuardPlugin or symfony's provided methods for this? // Add one or more credentials $user->addCredential('foo'); $user->addCredentials('foo', 'bar'); // Check if the user has a credential echo $user->hasCredential('foo'); => true // Check if the user has both credentials echo $user->hasCredential(array('foo', 'bar')); => true // Check if the user has one of the credentials echo $user->hasCredential(array('foo', 'bar'), false); => true // Remove a credential $user->removeCredential('foo'); echo $user->hasCredential('foo'); => false // Remove all credentials (useful in the logout process) $user->clearCredentials(); echo $user->hasCredential('bar'); => false or is the purpose of sfDoctrineGuardPlugin just securing the admin page and not the frontend logging system? thanks.

    Read the article

  • class composition instead of object composition?

    - by fayer
    I want a class property to be reference to another class, not its object and then use this property to call the class's static methods. class Database { private static $log; public static function addLog($LogClass) { self::$log = $LogClass; } public static function log() { self::$log::write(); // seems not possible to write it like this } } any suggestions how i can accomplish this? cause i have no reason making them objects, i want to use the classes for it.

    Read the article

  • database for streets world wide?

    - by fayer
    i use the downloadable geonames database for all countries, states, counties and cities in the world. but i wonder if there is a database for streets? so you could pick: country - state/department/district - (county/region) - city - street in whatever country you like? cause when i do a search for a street in google map i can see all the upper levels (country/region/city). is there a database you could download for mysql for this? there has to be a database for this, cause there are always national companies that provide this kind of information. where did they get it from? thanks in advance!

    Read the article

  • delete elements in xml?

    - by fayer
    i've got some elements in a xml document i want to delete. so i want to create another xml document without those elements. here is an example of how it looks like at the moment: <entity id="1000070"> <name>apple</name> <type>category</type> <entities> <entity id="7002870"> <name>mac</name> <type>category</type> <entities> <entity id="7002907"> <name>leopard</name> <type>sub-category</type> <entities> <entity id="7024080"> <name>safari</name> <type>subject</type> </entity> <entity id="7024701"> <name>finder</name> <type>subject</type> </entity> </entities> </entity> </entities> </entity> <entity id="7024080"> <name>iphone</name> <type>category</type> <entities> <entity id="7024080"> <name>3g</name> <type>sub-category</type> </entity> <entity id="7024701"> <name>3gs</name> <type>sub-category</type> </entity> </entities> </entity> <entity id="7024080"> <name>ipad</name> <type>category</type> </entity> </entities> </entity> i want to create another xml document without the sub-category and subject elements. so the new one will look like this: <entity id="1000070"> <name>apple</name> <type>category</type> <entities> <entity id="7002870"> <name>mac</name> <type>category</type> </entity> <entity id="7024080"> <name>iphone</name> <type>category</type> </entity> <entity id="7024080"> <name>ipad</name> <type>category</type> </entity> </entities> </entity> should i use simplexml/php or xslt to do this? are there other ways? would be great with some code examples...thanks!

    Read the article

  • understanding the models in MVC

    - by fayer
    i cant fully understand the models in MVC. so i am using symfony with doctrine. the doctrine models are created. does this mean that i don't have to create any models? are the doctrine models the only models i need? where should i put the code that uses the doctrine models: eg. $phoneIds = array(); $phone1 = new Phonenumber(); $phone1['phonenumber'] = '555 202 7890'; $phone1->save(); $phoneIds[] = $phone1['id']; $phone2 = new Phonenumber(); $phone2['phonenumber'] = '555 100 7890'; $phone2->save(); $phoneIds[] = $phone2['id']; $user = new User(); $user['username'] = 'jwage'; $user['password'] = 'changeme'; $user->save(); $user->link('Phonenumbers', $phoneIds); should this code be in the controller or in another model? and where should i validate these fields (check if it exists in database, that email is email etc)? could someone please shed a light on this. thanks.

    Read the article

  • solr plugin for symfony?

    - by fayer
    with symfony using doctrine is very easy cause its fully integrated into the framework. i wonder if there is a possibility to integrate solr with symfony too (eg, via plugin?) thanks

    Read the article

  • difference between sfWidgetFormI18nChoiceLanguage and sfFormExtraPlugin in symfony?

    - by fayer
    to add a list form that contains all languages one can use the widget sfWidgetFormI18nChoiceLanguage that is included in symfony or install a plugin called sfFormExtraPlugin and use its form sfFormLanguage. this is mentioned in http://www.symfony-project.org/jobeet/1_4/Doctrine/en/19 i wonder what the difference is? why should i use the plugin when the standard widget could display a list of all languages? thanks

    Read the article

  • select rows with column that is not null?

    - by fayer
    by default i have one column in mysql table to be NULL. i want to select some rows but only if the field value in that column is not NULL. what is the correct way of typing it? $query = "SELECT * FROM names WHERE id = '$id' AND name != NULL"; is this correct?

    Read the article

1 2 3 4 5 6  | Next Page >