예제 #1
0
파일: ORM.php 프로젝트: jasmun/Noco100
 /**
  * Overwrite to avoid PDO use
  *
  * @param string $query
  * @param array $parameters An array of parameters to be bound in to the query
  * @param string $connection_name Which connection to use
  * @return bool Response of PDOStatement::execute()
  */
 protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
 {
     self::_log_query($query, $parameters, $connection_name);
     if (self::usePdo($connection_name)) {
         // the default with pdo_mysql
         $statement = self::$_db[$connection_name]->prepare($query);
         self::$_last_statement = $statement;
         $result = $statement->execute($parameters);
     } else {
         // with wpdb: nothing to prepare, no statement...
         $result = true;
     }
     return $result;
 }
예제 #2
0
파일: ORM.php 프로젝트: jasmun/Noco100
 public static function init($config)
 {
     if (!self::$_is_init) {
         require_once dirname(__FILE__) . '/ORM/Idiorm.php';
         require_once dirname(__FILE__) . '/ORM/ORM.php';
         require_once dirname(__FILE__) . '/ORM/Wrapper.php';
         require_once dirname(__FILE__) . '/ORM/Model.php';
         if ((int) $config->use_pdo === 1) {
             IfwPsn_Wp_ORM_ORM::configure('use_pdo', true);
             IfwPsn_Wp_ORM_ORM::configure(sprintf('mysql:host=%s;dbname=%s', DB_HOST, DB_NAME));
             IfwPsn_Wp_ORM_ORM::configure('username', DB_USER);
             IfwPsn_Wp_ORM_ORM::configure('password', DB_PASSWORD);
             // UTF8 setting, see: https://github.com/j4mie/idiorm/issues/2
             IfwPsn_Wp_ORM_ORM::configure('driver_options', array(defined('PDO::MYSQL_ATTR_INIT_COMMAND') ? PDO::MYSQL_ATTR_INIT_COMMAND : 1002 => "SET NAMES utf8"));
         }
         self::$_is_init = true;
     }
 }
예제 #3
0
파일: Wrapper.php 프로젝트: jasmun/Noco100
 /**
  * Wrap Idiorm's create method to return an
  * empty instance of the class associated with
  * this wrapper instead of the raw ORM class.
  */
 public function create($data = null)
 {
     return $this->_create_model_instance(parent::create($data));
 }