Created
April 12, 2012 15:57
-
-
Save erochest/2368569 to your computer and use it in GitHub Desktop.
What's wrong with this?
This file contains hidden or 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
protected function _addFacetMappings() | |
{ | |
$sql = <<<SQL | |
INSERT INTO `{$this->_db->prefix}solr_search_facets` | |
(element_id, name, element_set_id, is_facet, is_displayed, is_sortable) | |
VALUES (?, ?, ?, ?, ?, ?); | |
SQL; | |
$stmt = $this->_db->prepare($sql); | |
// These get inserted fine. | |
$stmt->execute(array(null, 'image', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'tag', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'collection', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'itemtype', null, 1, 1, 1)); | |
$elements = $this->_db->getTable('Element')->findAll(); | |
$f = fopen('/vagrant/solr.log', 'w'); | |
foreach ($elements as $element) { | |
// This line produces the output I expect, so it is getting the elements and iterating over them. | |
fwrite($f, "\n+++ {$element['id']} => [{$element['element_set_id']}] '{$element['name']}'\n"); | |
// However, none of these actually get inserted into the database. | |
$stmt->execute(array( | |
$element['id'], $element['name'], $element['element_set_id'], 0, 0, 0 | |
)); | |
} | |
fwrite($f, "DONE\n"); | |
fclose($f); | |
} |
This file contains hidden or 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
protected function _addFacetMappings() | |
{ | |
$elements = $this->_db->getTable('Element')->findAll(); | |
$sql = <<<SQL | |
INSERT INTO `{$this->_db->prefix}solr_search_facets` | |
(element_id, name, element_set_id, is_facet, is_displayed, is_sortable) | |
VALUES (?, ?, ?, ?, ?, ?); | |
SQL; | |
$stmt = $this->_db->prepare($sql); | |
$stmt->execute(array(null, 'image', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'tag', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'collection', null, 1, 1, 1)); | |
$stmt->execute(array(null, 'itemtype', null, 1, 1, 1)); | |
$f = fopen('/vagrant/solr.log', 'w'); | |
foreach ($elements as $element) { | |
// This line produces the output I expect, so it is getting the elements and iterating over them. | |
fwrite($f, "\n+++ {$element['id']} => [{$element['element_set_id']}] '{$element['name']}'\n"); | |
// However, none of these actually get inserted into the database. | |
$stmt->execute(array( | |
$element['id'], $element['name'], $element['element_set_id'], 0, 0, 0 | |
)); | |
} | |
fwrite($f, "DONE\n"); | |
fclose($f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment