Jump to content

thehippy

Members
  • Posts

    209
  • Joined

  • Last visited

Everything posted by thehippy

  1. Foreign keys are a type of constraint (or condition) on a column and the foreign key condition is that the column data 'must be equal to a value in the other table's column.' So, you insert a value that already exists in the other (foreign) table and just insert it like any other value. The foreign table does need to be populated with values first before you can start adding to tables that reference the data. Hopefully that makes sense. This probably should have been put in a SQL forum.
  2. AND is being used as a logical operator and not as a string being passed to SQL, there's an extra parenthesis in there too. Try something along the lines of this... $dbWrite->delete('assignment_questions', array( 'question_id' => $question_id, 'assignment_id' => $assignment_id ) );
  3. I'd profile out using the SPL directory iterator versus what you have going at the moment, I would think it would be faster. You probably know this, but what you said previously about only searching for directories could be taken a couple of ways. Most APIs in most languages don't differentiate between a file and a directory while scanning without an additional call to the disc. When placed on the disc, file and directories use up an inode (or a variant mapping method), the inode contains meta data and data fragments. The difference being a file might span across many, many inodes to create the entirety of the file. When these functions are searching they grab the basic inode data, place (on disc) and name being all they usually need. This is to speed up things. Imagine a single php script called from a relative path, when called the php interpretor has to track down its own config, look through all them one at a time going through file and directories looking for the correct one. Then it loads up your include path and scans down all of those directories looking for your file. Discs are under a constant barrage of calls for info on disc objects. This also brings up a good point, use absolute paths if you can. With your loader, perhaps you could try creating a hash table lookup generated at release, your files probably aren't going anywhere then and it'll save on all the file scanning. IIRC that's what the new plugin loader for Zend Framework 2 uses.
  4. stuck with what? Sounds like a simple blog fits the requirements, pretty standard set of features.
  5. Also, if you're testing in your application, the extension_loaded function is useful. And if you're at the command a simple php -m will give you a list of loaded extension, though be warned some systems have a different config for command line usage than loaded with the web server.
  6. That's a bad way to do it. RMDBs are built on the design philosophy of creating relationships with data, a single cell for a single piece of data. Read up on 'Fundamentals of Relational Database Design', it'll help you as a developer better use databases. If Questions are unique to the product then you'll want to create a has many relationship from the Product to Questions. Product hasMany Questions. productID, name, description, ... questionID, productID, question -- Select Questions for a specific productID SELECT q.questionID, q.question FROM question AS q WHERE productID = # If Questions are not unique and many products can have many of the same questions, then you'll want to create a many to many relationship, this requires an extra table. This is the common way to reduce a database from having redundant data, in this case it gets rid of having duplicate questions in the table. product table - productID, name, description, ... question table - questionID, question, ... producthasquestions table - productHasQuestionsID, productID, questionID -- Select Questions for a specific productID SELECT q.questionID, q.question FROM question AS q, productHasQuestions AS h WHERE (h.productID = #) AND (q.questionID = h.questionID)
  7. I'm a bit of a tard, don't tell anyone though. You should be including the folder that contains the Zend folder, such as C:\wamp\zend\library\. Your book probably has includes such as require_once('Zend/Version.php'); ... not sure that's your problem atm, but it might be. A warning to you I manually setup Apache, PHP and the RMDB I'm using so I don't have any experience with the bundled installers and how they manage things. For which php.ini you should be editing, its entirely based upon the situation. From the command line PHP uses the one in its own directory, or the first one found in PATH. When you're using Apache2 the php.ini that gets used is the one configured with the PHPIniDir. The quickest thing to do would be to create a simple <?php phpinfo(); ?> script to see what's going on. My simple zftest.php file for testing a zend framework install. <?php require_once('Zend/Version.php'); echo "Zend Framework Installed Version: " . Zend_Version::VERSION; echo "<br /> Zend Framework Latest Version: " . Zend_Version::getLatest();
  8. I'd guess it was a path problem, given that you're just setting it up. Take a look at the path setup in /public/index.php, the location of both the application folder and the library folder are in there, verify that they are correct. Another thing, I've not seen an include_path setup using multiple include_path's in the php.ini file, I'm not sure if that would cause any problems. A single directive with all your folders separated by a semicolon is typical, such as include_path=".;c:\wamp\libraries\Zend;c:\wamp\pear;c:\wamp\libraries\smarty" Third thing, just to clear you up on it, the Zend folder within the library folder from the Zend installation archive is the correct one to include, you seemed hesitant about it in your video. Everything else are extras, experimental modules, docs, unit tests, et cetera. A troubleshooting and debugging tip, check Apache's error log and PHP's error log for more descriptive errors. The logs are typically in their perspective directories <Apache Dir>\logs and <PHP Dir>\log.
  9. Could you elaborate on 'spam words', its a bit vague. Akismet is a good service for stopping spam in general though its focused on comment and trackback spam for blogs, but can be adapted. If you're worried about bots spamming your site having an image captcha, that a user inputs on submit is definitely a good solution, reCaptcha is pretty much the industry standard on this technology nowadays but it can be implemented readily with some inventive GD image and font manipulation. Neither of the mentioned solutions is perfect, so make sure to build in some features for yourself to easily review the user content.
  10. Common practise varies on the environment and on experience of the developer I find. I've been following a Zend Framework structure a lot lately. /home/myusername/application /config /controllers /models /library /Zend /...bunch of other libs too /views /layouts /cache - Not a ZF convention but I like putting it here /session /compiledView /app /resources - Put stuff like fonts for image creation here, again not a ZF convention /home/myusername/public_html - Contains only what needs to be public, only php file is my index.php for most sites /css /js /images Personally I don't like to put anything in a public directory, even a subdirectory with strict access control in the off chance the web server config is improperly edited and the access control disappears. Its a bit of paranoid thinking, then again how valuable is your privacy? What's the cost if that information is leaked to the wrong people? Are there legal repercussions for disclosing that information? Its simple enough to keep most scripts and data out of a public folder and avoid some possible trouble down the road. As for your redirecting problem, how are you redirecting when a user logs? Something like the following? <?php session_start(); if( loggedIn($user) ) { destroy_cookie(); destory_session(); } header("Location: http://www.yoursite.com/"); exit; ?>
  11. I had this bookmarked, its not a pure (Player, Rank) example but a (Player, Points, Rank) example, which may work for you.
  12. Its programmer's preference on how you decide to store your zend_navigation menu, be it xml, config or just in a plain array. Doesn't affect functionality.
  13. You start by asking about general design, then get into 'what we' have type descriptions. I'm assuming you have an existing private code-base application. For database scaling solutions, server, schema ,query and index optimization, a MySQL DBA is a very valuable and worthwhile investment. You can post a job post on the MySQL forums with what your project needs are and requirements for a DBA or DB Developer are. Let me reiterate, this is worthwhile! You could also put your install on some expensive hardware, an iSeries server from IBM might be worthwhile, I think those start at around 14k USD. Throwing raw power at a DB is always a nice option. There are certainly things you can do on your own to make your application more efficient. Start with monitoring and profiling, identify your bottlenecks, be it queries, network latency, slow scripts, identify memory hogs. You can garner a great deal of info this way without affecting your application. With info in hand you can make changes to caching solutions, refactoring code for efficiency, server settings and so forth. Personally I'm not a fan of ORM solutions, they tend to slow me down and add a unnecessary layer between application and datastore. People tout the idea of platform independence, making your code more portable, but databases are as much an integral part of web applications as choosing the language you implement your application with, in my opinion at least. noSQL should not be an option unless you understand why its a good option, not because you've heard good things about it. It has a particular use-case scenario and doesn't perform well if that's not the case. The database (horizontal) partitioning you're asking about is to have the DB server fundamentally manage the data on disk rather than the operating system, most OSs cluster commonly opened files together, while the DBMS does the same with its data but better. MySQL doesn't support the partitioning of data across discs itself, where data could be split across multiple hard drives to gain the read and write access speeds of multiple discs. The closest solution do this is to setup your MySQL server with RAID solution, which does increase responsiveness. To have a database split over many servers, well the database isn't really split, replication is a common solution for database clusters, data is synchronized over many servers. There are one or many master servers that aggregate and sync data and many slave servers that deal with queries from applications. There is a bit of delay between slaves getting updated, but its usually minimal. Shards are independent instances of your entire database, usually on different physical servers and managed centrally. This requires some very strict data integrity checking and a mechanism for syncing data if you want to centralize the data. A modern example of shards are each of the individual world servers for WoW, each server is a shard, each server has a fundamental dataset, but each shard has its own independent data as well.
  14. array()->current() will not increment the internal array pointer in your while loop. foreach is optimized for this behaviour foreach ($res as $row) { echo $row['usr_username']; } And just to note, its common practise to use query builders in ZF over raw SQL. // Create a Zend_DB_Select object $query = $db->select(); $query->from( APP_TABLE_PREFIX . 'user', array('usr_username', 'usr_ldap_authentication')); try { // Connection and Query Attempt is made here $res = $db->fetchAll($query); } // What you can catch varies per adaptor, catch all catch (Exception $ex) { $log->err($ex); return ''; } foreach ($res as $row) { echo $row['usr_username']; }
  15. Setup Data Validation in your model, Cake if I recall automagically takes care of the error handling. You can create customized callback functions for non-standard checks quite easily.
  16. Wouldn't your problem be how the 'next' link is written, not your dropdown box?
  17. Without any errors to go off of all I can say is that Zend_Pdf has some PHP extension requirements, ctype, gd, iconv and zlib. Make sure those are installed in your PHP configuration. ZF expects a working PHP environment and as such can be overlooked easily.
  18. While the default behaviour in Cake is to bind a Model and Controller, it is not required, so no you don't need a catalog model. I'm frequently using Controllers without Models and Controllers with many Models, check out the Controller attributes in the documentation, specifically $uses.
  19. try php -f /HDDLogs/HDDProcess.php Is cron logging enabled? probably piping to syslog if it is. Does syslog show a successful run? Your script doesn't rely on any environment variables does it? cron's execution wont load up any of your shell variables from .login, .bash, etc. /usr/bin/php is php-cli, yes? though I dont think it should make a difference in this situation ... I'm running out of ideas
  20. Yeah this is usually done with some kind of AJAX interface now a days. We used to just do a call back to the form after a 'onChange' to reload the whole page with the form and new sub-select values.
  21. Are you running this as root? root's crontab has an extra field to designate a user to run as minute hour monthday month weekday user command
  22. Not totally related to the original post, but Geonames.org and MaxMind both have databases and APIs/Web services with Country, Region, City data. Their free data tends to be less accurate, but its very useful and way better than nothing.
  23. Basic Unix permissions come in a three digit octet sequence (ex. 755). Where the first digit relates to the owner permissions, the second digit to the group permissions and the third to everyone else. Pretty good explanation here. The situation is dependant on your group memberships and cron's group memberships so I'll leave you with a non permission based solution. $_ENV will contain some different variables from a command line execution versus a website/apache execution. I'd just detect one or more of those variables and execute my script or log/exit otherwise. I'll leave it up to you to find those variables.
  24. MySQL Workbench comes to mind, but it's not as visual as the MS Access or MSSQL query builder, but it is free. It's more of an intellisense IDE when it comes to query building. SQLMaestro has Code Factory for MySQL, which isn't quite up to the visual design of MS's query builder but close and it's fairly inexpensive. And what I currently use is Navicat for MySQL, is designed as more of a DBA tool and is a bit more expensive, but worth it IMO. Those are the tools I've used, I'm sure there's more just google for mysql query builder.
  25. Files handled by PHP are all temporarily uploaded the the upload_tmp_dir (PHP.ini setting), its the programmers' job to move them to a location of their choosing. As it turns out there's a handy function for moving uploaded files around named move_uploaded_file. Also, for future reference files are uploaded to a server via a HTTP POST method in most circumstances. move_uploaded_file( $_FILES["uploadfile"]["tmp_name"], $CustomPath . $filename);
×
×
  • 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.