Jump to content

poshpaws

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

poshpaws's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi all, I need to implement internationalization into an existing system. Unfortunately its a legacy system and theres not much chance of installing a framework and using any existing tools from that. I've looked up gettext and XLIFF, and in particular the Translate package in the Zend framework as I've heard classes from that could be used as stand alone 'module' and offer various different types of adapters. My reservation with gettext is that I heard it can't be used on multi-threaded apache servers (v2 and above), however aparently the Zend adapter (and I'm sure others like Symfony) solves this problem. I was just wondering if anyone has used any of these before, and their thoughts on each? And as far as adapters go, which would you recommend? Many thanks.
  2. Thanks for the link..this is what I was wanting to do. I've read about this before (ACID etc), but never really applied it. Do any of you use transactions with mysql for updates/inserts? How would COMMIT and ROLLBACK be called from a php script? (I don't have access to the command line prompt). Would anyone use these for a CMS, intranet etc? I'm trying to learn some best practice techniques. Fenway: Would you test SQL statements with LIMIT 0 and actually place them in your scripts before calling the insert/update queries? Or would this be more for testing your queries once to make sure they dont return any errors?
  3. It happened a while ago, and I think it was to do with one of the ID's not passing correctly. My question was more general, just to see if it was possible to do something like this. Although validation should take care of this, sometimes it falls through the net and I wanted to be sure there would be no probs with the DB.
  4. By test I mean, to somehow test if a query would work without actually executing it. This is to get around problems like this: 1st "INSERT INTO User..." - executes fine, no errors 2nd "INSERT INTO User_group.." - error here Sometimes I may have 5/6 insert statements, which makes it trickier. Particularly using mysql_insert_id.
  5. Hi, I have a script where I update multiple tables. For example: products, product_spec, product_type, order etc. The way I do this is that I just execute the mysql_query("x") in succession. If one fails, it returns an error and halts the script. I've had situations where the first few queries were successful, and then one fails so the rest dont execute. As the tables reference each other, this causes errors when I try to view the data and the only workaround is to manually delete the entries in the DB. So I was wondering, is there a way to 'test' a query first, without actually executing it? I want to make sure that all queries will be successful before executing them, so either all are executed or none. I use mysql_insert_id from previous queries, to store in other tables, so I'm wondering how this would be done.
  6. I'm thinking of applying Code Igniter for rebuilding a section of a website. It's not feasible to re-do the whole site at the moment (although it would be ideal). I'm not sure how it would link in to the other parts (theres already auth,db and template fuctions), but if I have to do it anyway, why not start with this? Otherwise, I'm just continuing this messy cycle of procedural code and 100s of functions. Or perhaps another way, would be to customise the framework to work with my existing site, and make it backwardly compatible with my old functions and includes and eventually move it to the new classes etc. Or I could just forget about the framework for now, and build new parts using classes in OOP. Opinions?
  7. Thanks for that, I think I'm getting the hang of it now. Looking back at what I originally did, the multidimensional array is quite messy! The total() method in Order and the value() in Product makes a lot more sense. I suppose I could also call value($type) and call whichever $type I wanted e.g. setupCost or monthlyCost, and have that return it.
  8. If I were to use an accessor method such as $u->get_name(), how could I return several values in that method? As far as I know, you can do: return $FirstName; To return several values (FirstName, SecondName, E-mail) in the same method, is the only way to create an array and return that? It seems like a lot of methods if its just to return single properties. Pass the user object into the invoice: $u = new user( 'jeff' ); $i = new invoice(); $i->invoice_user( $u ); invoice_user would then access user methods, like $u->get_name(). or invoice could be a method in the user object, so then you could do: foreach( $users as $user ) $user->invoice(); monk.e.boy
  9. What I meant was I wanted the Invoice class to be able to get the total costs of all products. Suppose I pass several product objects, I'd like it to be able to hold those, and add them all together. The only way I can think of doing this is a multidimensional array (in the Invoice class) e.g. Product[$x]["$monthly_cost"], and to loop through $x to get the sum of the monthly cost of all products. In the example you gave, its just adding the monthly and setup cost of one product (one instance), where as I'd like to be able to pass several instances.
  10. I've been playing around with classes and objects over the weekend to practice more in OOP, and I came across a few things I'm unclear about. Firstly, as its advised to normally set your variables to private/protected, these values would be returned by a method inside that class. Now, suppose I create an instance of that class, and it contains 3 private variables. Which would be the best way to pass these to another class? I would create a method, and return them in an array, though I'm not sure this is the best way. For example, suppose I had a class (User) and I wanted to pass its properties (FirstName, SecondName, E-mail etc..) to another class (Invoice) to send that person an email. Secondly, suppose I had a class (Invoice) and a class (Product). I also have 2 other classes, Product_web and Product_hosting which extend Product. Product contains a public $MonthlyCost and $SetupCost variable. Now, in the Invoice class I create a method to pass products: loadProduct($Product). I create seperate instances for Product_web and Product_hosting and pass each to loadProduct(). I also have a method totalCosts() which calculates the total cost of all products. Here is the bit that confuses me. How would I calculate the total of all $MonthlyCosts and $SetupCosts? The way I did this was using this method in the Invoice class, to create a multidimensional array. function loadProduct($product){ $myKey = count($this->Products); $myKey++; foreach($product as $var => $value) { $this->Products[$myKey]["$var"] = $value; } } Then in the totalCosts() method I would loop through the array. But really I only want the values $MonthlyCost and $SetupCost, instead of returning all properties of the Product. Any ideas? I hope I explained this well
  11. After reading up on OOP in PHP5, I'm now thinking of how I can apply it to where I used to use procedural code. I understand the textbook examples (though they usually tend to be quite basic) and the idea of designing classes according to 'real world' thinking, but when I try and think how to switch my site to OOP I get a bit lost. I can't really get my head round identifying classes (where there just used to be functions) and child classes. I'm looking at some PHP frameworks to try to understand this better, but can anyone suggest any other ways?
  12. Thats interesting. I only recently discovered MVC patterns, I didnt know there were so many different types. I'll definitely have a look at that book. How closely are design patterns linked to OOP?
  13. Thanks for your very informative reply I already use a type of template system (although really just a set of functions to separate the html from the php code and not so much the seperate layers). I never quite thought of it from an MVC perspective until now. I'll try out some other template engines and move on to CodeIgniter/Cake once I get a better idea. Out of interest, have you found what you learned of MVC/OOP in PHP to have helped with programming in other languages too? I havent done any OOP in PHP4 (ive stayed clear of it as I heard its a bit confusing, and not strictly OOP either) and instead I've learned it in PHP5. As most of it has been re-written, I'm a little concerned that using CodeIgniter/Cake would be a little confusing due to its compatibility with PHP4. Presumably if its backwardly compatible, would that mean it would use PHP 4's OOP syntax? If this is the case, perhaps it would be better to stick with frameworks only for PHP 5? Thanks!
  14. I was doing some searching yesterday, and came across this link: http://builder.com.com/5100-6371-5163311.html As I dont have access to the ini file, I had to insert a bit of code at the top to include it all. I used the following to test if it was installed correctly, which gives a list of all the PEAR packages. <?php // Include the appropriate PEAR classes require_once("PEAR/Info.php"); $pearinfo = &new PEAR_Info(); $pearinfo->getPackages(); $pearinfo->getConfig(); $pearinfo->getCredits(); ?> I guess if its not returning any errors it means its working fine?
  15. Actually, I noticed running a phpinfo() returned the following: soap Soap Client enabled Soap Server enabled If SOAP is enabled, wouldnt that mean that PEAR is already installed?
×
×
  • 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.