title: using prestashop DB API in a php-cli project for testing?
body: <p>I have prestashop 1.7.2.0 installed on php 7.1.7 on nginx server.</p>
  <p>I'm writing a module for prestashop and it will be way faster for me if I could use prestashop API for PHP-CLI in order to test the installation and the operation of my module.</p>
  <p>specifically now I need to get <code>Db::getIntance()</code> to work.</p>
  <p>so far I created the following script:</p>
  <pre><code>&lt;?php
  const PRESTASHOP_DIR = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'prestashop';
  
  spl_autoload_register(function ($className) {
      if (0 === strpos($className, 'InstallControllerConsole')) {
          $fileName = strtolower(str_replace('InstallControllerConsole', '', $className));
          require_once PRESTASHOP_DIR.'/controllers/console/' . $fileName . '.php';
      }
      if (0 === strpos($className, 'InstallControllerHttp')) {
          $fileName = strtolower(str_replace('InstallControllerHttp', '', $className));
          require_once PRESTASHOP_DIR.'/controllers/http/' . $fileName . '.php';
      }
      if (file_exists(PRESTASHOP_DIR.'/classes/' . $className . '.php')) {
          require_once PRESTASHOP_DIR.'/classes/' . $className . '.php';
      }
      if (0 === strpos($className,'Db') &amp;&amp; file_exists(PRESTASHOP_DIR.'/classes/db/'.$className.'.php')) {
          require_once PRESTASHOP_DIR.'/classes/db/'.$className.'.php';
      }
  });
  
  require_once(PRESTASHOP_DIR.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'db'.DIRECTORY_SEPARATOR.'DbPDO.php');
  require_once(PRESTASHOP_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.inc.php');
  require_once(PRESTASHOP_DIR.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php');
  
  $a = Db::getInstance();
  </code></pre>
  <p>and I get the following Error:</p>
  <pre><code>PHP Fatal error:  Class 'Db' not found in /Volumes/osx-storage/projects/luckylee/prestashop/prestashop/classes/db/DbPDO.php on line 32
  </code></pre>
  <p>when I tried to grep prestashop project for <code>Db</code> class I could only see an abstract class which means that something else extends and init it.</p>
  <p>any idea how to resolve this ?</p>
  <h1>update</h1>
  <p>it seems that I pointed to a pestashop directory that was just unzipped and not installed. when I pointed it to a directory that prestashop is properly configured, requiring only <code>config.inc.php</code> is enough.. but</p>
  <p>when I do an insert to a table that I created, nothing happens and it doesn't return an error. any ideas?</p>
  <p>I run the command:</p>
  <pre><code>    Db::getInstance()-&gt;insert(_DB_PREFIX_.'tuxinmod_cartype',['id_tuxmod_cartype'=&gt;0],true);
  </code></pre>
  <p>and no changes in the database. why? :)</p>
  <p>I created the table ps_tuxinmod_cartype.. and still i should have gotten an error and I don't. what am I missing ?</p>
  <h1>update</h1>
  <p>ok omitting the <code>_DB_PREFIX_</code> from the insert statements do work! :) yay!!
  but I really need to know when there is an error.</p>
  <p>these are my error related configuration php.ini</p>
  <pre><code>display_errors =&gt; STDOUT =&gt; STDOUT
  display_startup_errors =&gt; On =&gt; On
  error_append_string =&gt; no value =&gt; no value
  error_log =&gt; no value =&gt; no value
  error_prepend_string =&gt; no value =&gt; no value
  error_reporting =&gt; 32767 =&gt; 32767
  html_errors =&gt; Off =&gt; Off
  ignore_repeated_errors =&gt; Off =&gt; Off
  log_errors =&gt; On =&gt; On
  log_errors_max_len =&gt; 1024 =&gt; 1024
  track_errors =&gt; On =&gt; On
  xdebug.force_display_errors =&gt; On =&gt; On
  xdebug.force_error_reporting =&gt; 32767 =&gt; 32767
  xdebug.show_error_trace =&gt; On =&gt; On
  </code></pre>
  <p>i see no errors what so ever when I provide a table that doesn't exist</p>
  <p>any ideas?</p>