This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
templates: | |
home: | |
areas: | |
header | |
body | |
footer | |
slots: | |
splash: | |
type: aImage | |
logo: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm going to examine a plausible, nontrivial query that comes up for client sites and | |
consider how it would be implemented in both MongoDB and a MySQL back end that attempts | |
to support a lot of the capabilities we like in MongoDB. | |
I'm not going to look at how we retrieve the inner contents of a page (nested contents) | |
or information about subpages (related contents) because I have a pretty good idea how | |
we want to cope with those bits in both cases. | |
The query syntax here is just pseudocode, I'm not proposing it: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = dirname(__FILE__) . '/profile.csv'; | |
$out = fopen($file, 'a'); | |
$load = @file_get_contents('/proc/loadavg'); | |
$load = preg_split('/ /', $load); | |
$load = $load[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a situation where a unique index error will occur. Try to save the | |
* object again after making the relevant field unique. Expected behavior: | |
* object saves second (or third...) time and we wind up with ten objects. Actual behavior: | |
* we get just one object and there is a unique index error after all ten save callbacks | |
* have already been invoked "successfully"! This is really strange, even stranger than I | |
* thought. Maybe the index is not applied yet somehow and I need to wait on the schema | |
* being ready? | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a situation where a unique index error will occur. Try to save the | |
* object again after making the relevant field unique. Then do an update on one of the objects. | |
* | |
* Expected behavior: each object after the first saves successfully the second (or third...) time and we wind | |
* up with ten objects. Actual behavior with current Mongoose: we wind up with one object because the | |
* isNew flag is never reset to true when an insert fails. Behavior with my pull request: the isNew flag | |
* is reset if an insert (not an update) fails, allowing save handlers to try again on error after doing things | |
* like making slugs more unique. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extend any Mongoose model that has a unique index on a 'slug' field so that | |
// if a unique index error occurs on 'slug', a random digit is added to the slug | |
// and the save operation is retried until it works. This is concurrency-safe even | |
// if you have lots of inserts going on from multiple machines etc. | |
// | |
// By Tom Boutell, [email protected] | |
// | |
// NOTE: YOU MUST HAVE THIS PULL REQUEST... https://github.com/LearnBoost/mongoose/pull/837 | |
// | |
// (As of this writing that commit is not in LearnBoost/mongoose yet.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('NUM_TESTS', 1000); | |
$before = memory_get_usage(true); | |
$test = array(); | |
class Foo | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macintosh-5:~ boutell$ set | grep PATH | |
MANPATH=/opt/local/share/man: | |
PATH=/Users/boutell/mongodb/bin:/usr/local/bin:.:/Users/boutell/bin:/Users/boutell/.gem/bin:/opt/symfony1.4/data/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/Users/boutell/personalassistant/festival/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/pktools/bin | |
macintosh-5:~ boutell$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If there are no matches, getSingleScalarResult will throw an exception | |
try | |
{ | |
$this->numResults = $countQb->getQuery()->getSingleScalarResult(); | |
} catch (\Doctrine\ORM\NoResultException $e) | |
{ | |
// This happens when zero rows are returned | |
$this->numResults = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In my Search entity class: | |
/** | |
* @ORM\ManyToOne(targetEntity="Posting", inversedBy="words") | |
* @ORM\JoinColumn(name="posting_id", referencedColumnName="id", onDelete="cascade") | |
*/ | |
protected $posting; | |
// Later, when I want to delete the Search objects for a given Posting entity: |
OlderNewer