Note that there are some explanatory texts on larger screens.

plurals
  1. PODoctrine SQL/table generation failing
    text
    copied!<p>I am trying to make Doctrine generate SQL from a set of models that I created earlier with a YAML schema. Using the code below which comes from the manual the output should be a set of queries.</p> <pre><code>&lt;?php // test.php require_once('bootstrap.php'); try { $models = Doctrine_Core::generateSqlFromModels('models/generated'); echo '&lt;pre&gt;'; var_dump($models); echo '&lt;/pre&gt;'; } catch(Exception $e) { echo $e-&gt;getMessage(); } </code></pre> <p>However, the result of this code is:</p> <pre><code>NULL </code></pre> <p>while it should return a string with the SQL queries, as said before. </p> <p>I've also tried the following:</p> <pre><code>&lt;?php // test.php require_once('bootstrap.php'); try { $result = Doctrine_Core::createTablesFromModels('models/generated'); echo '&lt;pre&gt;'; var_dump($result); echo '&lt;/pre&gt;'; } catch(Exception $e) { echo $e-&gt;getMessage(); } </code></pre> <p>but that also returns:</p> <pre><code>NULL </code></pre> <p>I was not able to find the solution in the manual, the API reference or in the Doctrine core files. I hope someone here knows.</p> <p>Thanks in advance.</p> <p><strong>Update:</strong> It can not be because of <a href="http://groups.google.com/group/doctrine-user/browse_thread/thread/14434aca4c021417/d6238b9b515c176b?lnk=raot&amp;pli=1" rel="nofollow noreferrer">this</a> (old?) bug, because I have no table name that starts with A or B.</p> <p><strong>Update:</strong> My bootstrap.php looks like this:</p> <p> <pre><code>/** * Bootstrap Doctrine.php, register autoloader specify * configuration attributes and load models. */ require_once(dirname(__FILE__) . '/lib/vendor/doctrine/Doctrine.php'); spl_autoload_register(array('Doctrine', 'autoload')); $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection('pgsql://user:pass@localhost/dbname', 'doctrine'); $manager-&gt;setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); $manager-&gt;setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL); $manager-&gt;setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE); </code></pre> <p><strong>Update:</strong> I've changed the line:</p> <pre><code>$manager-&gt;setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE); </code></pre> <p>to:</p> <pre><code>$manager-&gt;setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_AGGRESSIVE); </code></pre> <p>but the output of</p> <pre><code>print_r(Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels('models/generated'))) </code></pre> <p>is still an empty array.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload