Source for file intuition.dbconnection.php

Documentation is available at intuition.dbconnection.php

  1. <?php
  2. /**
  3. @package    jelix
  4. @subpackage db_driver
  5. @author     Yannick Le Guédart
  6. @copyright  2007 Over-blog, 2007 Yannick Le Guédart
  7. @link       http://www.jelix.org
  8. @link       http://www.sinequa.com
  9. @licence    http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  10. */
  11.  
  12. /**
  13.  *
  14.  */
  15. include (LIB_PATH 'intuition/Intuition.inc');
  16. /**
  17. @package    jelix
  18. @subpackage db_driver
  19. */
  20. class intuitionDbConnection extends jDbConnection {
  21.     /**
  22.     * The intuition session.
  23.     * @access private
  24.     * @var object 
  25.     */
  26.     private $_iSession
  27.  
  28.     public function beginTransaction (){
  29.         return $this->_doExec ('BEGIN');
  30.     }
  31.  
  32.     public function commit (){
  33.         return $this->_doExec ('COMMIT');
  34.     }
  35.  
  36.     public function rollback (){
  37.         return $this->_doExec ('ROLLBACK');
  38.     }
  39.  
  40.     public function prepare ($query){
  41.         throw new JException (
  42.             'jelix~db.error.feature.unsupported'
  43.             array ('intuition','prepare'))
  44.     }
  45.  
  46.     public function errorInfo (){
  47.         return 
  48.             array 
  49.                 'HY000',
  50.                 $this->_iSession->status ()
  51.                 $this->_iSession->status ());
  52.     }
  53.  
  54.     public function errorCode(){
  55.         return $this->_iSession->status ();
  56.     }
  57.  
  58.     protected function _connect (){
  59.         $this->_iSession new iSession ()
  60.         
  61.         if (!isset ($this->profile['port'])){
  62.             $this->profile['port'8088;
  63.         }
  64.         
  65.         $connectionArray array (
  66.             'host'              => $this->profile['host'],
  67.             'port'              => $this->profile['port'],
  68.             'read_only'         => 1,
  69.             'charset'           => in_UTF8,
  70.             'database'          => $this->profile['database'],
  71.             'user'              => $this->profile['user'],
  72.             'password'          => $this->profile['password'],
  73.             'page_size'         => 20,
  74.             'max_answers_count' => 1000,
  75.             'default-language'  => 'en'
  76.             );
  77.  
  78.         $cnx @$this->_iSession->connect ($connectionArray);
  79.         
  80.         if ($cnx){
  81.             return $this->_iSession;
  82.         }else{
  83.             throw new Exception ($this->_iSession->status ());
  84.         }
  85.     }
  86.  
  87.     protected function _disconnect (){
  88.         return $this->_connection->in_close();
  89.     }
  90.  
  91.     protected function _doQuery ($queryString){
  92.         // Avant tout, on enlève les retours-chariots
  93.         
  94.         $queryString str_replace (array ("\n""\r")" "$queryString);  
  95.         
  96.         // Exécution de la requète 
  97.         
  98.         $queryResult $this->_connection->in_query ($queryString);
  99.         
  100.         if (is_object ($queryResultor 
  101.             (is_numeric ($queryResultand $queryResult 0)){
  102.  
  103.             $rs                 new intuitionDbResultSet ($queryResult);
  104.             $rs->_connector     $this;
  105.         }else{
  106.             $rs false;
  107.             throw new Exception ($this->_iSession->status ());
  108.         }
  109.  
  110.         return $rs;
  111.     }
  112.  
  113.     protected function _doLimitQuery $queryString$offset$number)  {
  114.         $queryString.= ' SKIP ' $offset ' COUNT ' $number;
  115.         $result $this->_doQuery($queryString);
  116.         return $result;
  117.     }
  118.     
  119.     protected function _doExec ($query){
  120.         // Avant tout, on enlève les retours-chariots
  121.         
  122.         $queryString str_replace (array ("\n""\r")" "$queryString);  
  123.         
  124.         // Exécution de la requète 
  125.         
  126.         $queryResult $this->_connection->in_query ($queryString);
  127.         
  128.         return $queryResult;
  129.     }
  130.  
  131.     public function lastInsertId ($fromSequence=''){
  132.         throw new JException (
  133.             'jelix~db.error.feature.unsupported',
  134.             array ('intuition','lastInsertId'))
  135.     }
  136.  
  137.     protected function _autoCommitNotify ($state){
  138.         throw new JException (
  139.             'jelix~db.error.feature.unsupported'
  140.             array ('intuition','_autoCommitNotify'))
  141.     }
  142.  
  143.     /**
  144.      * @todo support of binary strings
  145.     */
  146.     protected function _quote ($text$binary{
  147.         return quote ($text);
  148.     }
  149. }

Documentation generated on Thu, 22 Mar 2012 22:13:47 +0100 by phpDocumentor 1.4.3