Jump to content

gizmola

Administrators
  • Posts

    5,882
  • Joined

  • Last visited

  • Days Won

    139

Everything posted by gizmola

  1. Yes any queries you have that are included in the where clause should have an index created on them. The only exception would be low cardinality values (for example a status flag or boolean) although those can be part of a multi-column index. As far as loading speed you can probably improve that using one or more of the suggestions provided here: http://dev.mysql.com/doc/refman/5.1/en/insert-speed.html If you're using INNODB tables you want to make sure you turn auto commit off.
  2. In that template he provided, yes, good point.
  3. How are you loading the rows currently?
  4. Menus that expand and contract are driven by css and javascript. In the old days people often called this DHTML. If you can isolate the data in the queries, and that data is bringing back the menus as expected, then you should be able to slot in any menu system, and there are an untold number available. Find one that is documented and easy to understand and replace that gobbledygook code with something clean and maintainable.
  5. What have you tried? I suggested that you: Put the mail chimp code into a file named mailchimp.inc.php There should NOT be a <?php at the top. Simply put that code exactly as is, in the file. This file should be in the same directory as your template. In the template add: include('mailchimp.inc.php');
  6. Given what I provided, and a little googling and reading, you should have what you need.
  7. Adding/altering tables are done with DDL commands (CREATE TABLE, ALTER TABLE). Listing tables is most easily done with the SHOW TABLES command. To actually manipulate an existing table, there is INSERT and UPDATE. In short, you need to learn basic SQL syntax.
  8. Yes, however, the file should be named something like newsletter.php or newsletter.inc.php. It should include just the HTML, utilizing the technique I illustrated above. It sounds like you don't need any php in there, but you can drop into php if you need to inside the file. When you include it, php will insert the html at that point in your header file.
  9. PHP allows you to easily jump in and out of HTML. <!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <h1> <?php echo 'It's ' . date(); ?> </h1> </body> You can also use a heredoc in circumstances like the one you describe: $form = <<<HERE <form id="newsletter"> ..... Form code </form> HERE; echo $form; Heredocs will even interpolate variables, so they are an excellent hybrid option. If you have pure html, then I'd drop into HTML at the point you need to include it.
  10. Your new server is set to SQL Strict mode. Your old server is not, thus it is downgrading the null to a 0. Take a look at this page: http://dev.mysql.com/doc/refman/5.0/en/sql-mode.html As you can see there are quite a lot of different options available to tweak the behavior of the server. Probably the strict server has something like this in its my.cnf file: # Set the SQL mode to strict sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" STRICT_TRANS_TABLES will cause that sort of insert to error out. You will want to diff the mysql configurations on the two servers, and compare the my.cnf for each to pinpoint the specific difference between the two. However, most likely it's the STRICT_TRANS_TABLES setting that explains the difference. On the old server, this setting is not being used, so the server is generating a warning instead, but otherwise creating the row.
  11. While there are places for Ajax, I don't think it's called for in this case. A typical solution is to use a "flash message". You can easily implement something like this with Twitter Bootstrap, and php sessions. Basically, the idea is that your edit script will do the update, set a session variable with the "Flash message" and redirect using header("Location: ..."); Your markup of your asistencia.php page, then simply needs to include some code that checks for the existence of the session variable, and if it does exist, displays the Message Box at the top of the asistencia.php page. You can create something like this by hand of course, but if you don't already have some helpers, bootstrap might be a helpful addition. At very least, these alerts will give you an example of what you're trying to achieve: http://getbootstrap.com/components/#alerts Typically you make them "dismissible" so that the user can click on the x to dismiss the message. You can generalize inter-page navigation and errors using this idea.
  12. I think that people will move rapidly to one of the forks if Oracle makes MySQL close source. That would be a mistake, and one that doesn't really make sense, since they already have thier flagship Oracle database product and continue to make huge revenue with that. Migration shouldn't be a huge problem, although it certainly could be disruptive to a production company with a large dataset. As for having a relational database "default" that suggests that a relational database ought to be installed by default in your linux distro. I don't think there's any reason for that -- people can install an RDMBS if they need one easily enough, and when they do need one, that should be left up to the package providers to support. I far prefer not having a lot of things preinstalled on a server, so that I don't have to worry about uninstalling things I don't need.
  13. Renatov, For some people, the concern about what might happen to the mysql license is very important. I am not in that camp at present, and don't despise Oracle and everything it stands for on principle. It's going into the 4th year since Oracle bought Sun, and the sky has not fallen, nor has Oracle stopped enhancing it, or pulled it off the market, or closed sourced it. I'm sure they are much more concerned with MongoDB than they are with alternatives to MySQL. Still it's no surprise that people would be very interested in what the mysql founder is doing with his fork and embrace that. So it's no surprise that MariaDB is default in some distributions, although I don't think a relational database should be the default in a distribution in the first place. For many people, there is no noticeable difference between the two, and have more in common in their lineage than differences. I personally never use mysql/myisam, and instead use the innodb engine when I use mysql. At this juncture there is a choice you have to make with mariadb -- do you utilize the Xtradb (innodb fork) or innodb as an engine. It's interesting looking at, but I'm not sure that there's any huge advantage to mariadb w/innodb or xtradb for that matter, but perhaps for some uses there might be. There may in some cases be performance improvements in MariaDB and there are some interesting edge-case plugins that exist for it, none of which I see as essential. A really good summary exists here: http://slashdot.org/topic/bi/mariadb-vs-mysql-a-comparison/ With that said, there is probably a lot about mysql you really want to learn, before you start concerning yourself with this issue. In conclusion, there is no real difference from the client/php perspective between the two right now.
  14. Agree 100%. I've had these types of conversations with people probably 50x over the years, I have NEVER seen a case that didn't involve a patent. Every other business person I talk to, who has an idea, is convinced their idea is amazing and original and worth a billion dollars.
  15. Actually the license in your code is enough. When you select the developer you want to review it, simply create an agreement that states the terms, which helps you establish how the developer came to see your code and on what date, should anything ever transpire. After that, a case of code duplication or theft would be based on being able to show that the code was copied in whole or part. Having some other sort of agreement isn't going to make that case more viable, and as others have stated, trying to cook up something more onerous will only get in the way of your attempts to hire someone competent to do the review.
  16. They have a Vim plugin. You can run vim in the terminal. Why not just use that? There are also extensions for chrome, firefox and safari.
  17. I would recommend looking at Dependency Injection to help with the decoupling. DI is an OOP design pattern popularized by OOP guru Martin Fowler, that's the foundation of Java frameworks like Spring, and in the PHP world Symfony2 and ZF2 to name just a few. There's a great introduction in this series of articles by Symfony project founder Fabien Potencier. In your case, you would pass your db object to the Incident_Row class in its constructor, rather than depending on a load() method to create it. class Incident_Row { private db; public function __construct($db) { $this->db = $db; } Later when you create an Incident_Row object, you have a number of options ranging from creating the db class on the fly to using a global/registry/singleton db class. $ir = new Incident_Row(new db()); // Or maybe an independent connection? $db = new db(); $ir = Incident_Row($db); This helps to keep specific db code out of the Incident_Row() class, although in this example, it's probably hard to see how that might be an advantage if you're calling class db specific methods inside Incident_Row(). If however, Incident_Row was written to a specific interface, you could derive a class from db() that wraps it, while implementing the interface. In other words, you have to come up with a generic db api to call rather than using the mysql specific one. This is the approach taken with design patterns like ActiveRecord (Ruby on Rails) and PHP ORM's like Doctrine or Laravel Eloquent implement. This would theoretically lead you to a point where you could interchange database connection objects and the Incident_Row class would work exactly the same way. So, for example, if you passed a Postgresql connection your code would still work. More practically, it makes it trivial to have code that is "environment" aware, so that you on setup configurations for each environment, and all the other code will work without issue.
  18. You can hook up xdebug to a lot of different editors. With that said, in order for a debugger to work, you need some sort of editor to load code and display it for step through. Most people are using one of the more popular PHP IDE's (PHPStorm, Eclipse PDT/Zend Studio/ Netbeans, etc) and understanding how xdebug works and what you have to do to utilize it isn't exactly point and click, depending on your development setup. For example, I wrote an article on how to get things setup with Eclipse/PDT some years ago, and it's not the easiest thing in the world to get started with. Take a look at it if you're interested.
  19. You're getting these Notices because at runtime, you are not passing the url parameter ..... your site?flag=some_value A notice is not necessarily an error, but your code tends to be more reliable if you work to eliminate them. But it does not necessarily mean your code won't work right. You can turn down the error level to exclude notices and many production sites do exactly that. <?php if($_GET['flag'] == "success") { ?>A couple of stylistic suggestions. 1. When you have if-then-else-otherwise-etc blocks, the code will be cleaner if you use a switch statement. 2. To check whether an array contains a particular key you have 2 primary options: array_key_exists or isset. Putting this into practice: if (isset($_GET['flag'])) { switch ($_GET['flag']) case 'success': // Success code here break; case 'exists': // exists code here break; case 'error': // error code here break; default: // If the code got here, then flag was something you didn't expect. // What do you need to do in that case? } }
  20. I'm not sure what you mean with the "supporting the devil comment." I have been using the AWS platform quite a bit the last few years, and this is where Amazon linux is a good option. It's closer to RHEL and Centos, but an important concern with AWS is that your OS will be run as a Xen guess and should have paravirtualization patches and stability in a virtualized environment. Centos is based on RHEL. They basically take the SRPM's, strip out the RHEL specific things, add some replacement bits and offer it up as Centos. RHEL has long been known for its focus on servers, and its contributions to Linux in general. Often users entry point into the os is through the package management and installation system. For me, I long ago learned rpm extremely well, and subsequently, yum, which wraps it and adds repository support. These are synonymous with dpkg and apt in Debian. At the end of the day, aside from these different package management systems, there are more similarities than differences in these distros.
  21. I didn't have a chance to see the replies to this until today, but in regards to interfaces vs. abstract methods, they can be used relatively interchangeably in many cases. However, the big difference is that a class can implement multiple interfaces, whereas in PHP's single inheritance system, a subclass can only inherit from a single superclass. You often see interfaces used in frameworks, where they expect people to write their own classes, that will then interact with the rest of the framework. Authentication is a good example, where you will often have a member class, often based on model base classes. In order to get the class to play with the generic authentication system, they'll provide an interface that the class needs to implement. This keeps everything decoupled and highly flexible in terms of how the framework user decides to store users --- be that in flat files, a database or a document store, while still insuring that it will be usable with the rest of the authentication system.
  22. There are times when you want to create a number of subclasses that all inherit from the same base class, but insure that the base class can not be instantiated itself. A simple example would be a zoo simulation where you decide that you want to have a factory class that can "make" new animals. When your application needs to create a new lion, for example, you don't want to have to write the same code over and over, when you can instead have completely generic code that creates animals of any type. Once an animal object is created, you will probably need to call some standard methods, and again if you based all your specific animal classes off an abstract animal class, your non-abstract methods can be called. Imagine you need some code that Will store an animal name, birthdate, gender and location in a table. You may decide that for each animal class you'll have a seperate table with the same name as the class. So in this example, you will have a lion table in the database. In your abstract animal class you might have: //Animal class. public function saveNew() { $table = get_class($this); $this->db->$table->insert(array('name' => $this->name, 'birthdate' => $this->birthdate, 'location' => $this->location, 'gender' => $this->gender)); } Needless to say, you will not have an 'animal' table, so making the baseclass abstract provides some protection against issues with saveNew(). It also provides a standard set of methods the factory class can depend on, so it can feature code like: // Animal Factory class public function makeAnimal($type, $location) { $animal = new $type($location); $animal->setGender(); $animal->setName(); $animal->saveNew(); } This code can be depended upon to work for any animal class that inherits from 'Animal'. setName() is an example where you might want to have an abstract method, assuming that the rules for animal names would be different for each different type of animal. The factory class will call setName(), but it is up to you to actually write function setName() when you create each individual class. SetGender()_ is another example, where you might lookup the relative ratio of male to female animals in a table where each row is named by class. While you would have a row for lion, elephant and crocodile, you'll have no row for animal. When trying to really dig into these ideas, you'll quickly find yourself gravitating towards "Object oriented design patterns". The books on this subject will provide specific examples that should help you understand why the oop features in php were implemented in ways that the manual does not.
  23. mail() depends on the configuration of your specific server, and the underlying mail transfer agent mechanics. I don't see anything obviously wrong with your code, although there could be something subtle. If the mail() function is succeeding, you need to debug at the MTA level. For example, if you were on a linux server and the mail is being dumped off to sendmail or postfix there are ways to determine if the mta is successfully delivering the mail. Mail server configuration also includes details about DNS MX, SPF and DKIM, not to mention the core SMTP standard. If you're just developing on a local workstation its probable that you don't have a working mail configuration OR you do have one, and the mail is being delivered, but due to the lack of the aforementioned environment, your mail is being spam filtered or outright rejected.
  24. What would you like us to do exactly? You have provided absolutely no code.
×
×
  • 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.