Пример #1
0
 public function execute(array $input_parameters = null)
 {
     // clear bound column types
     $this->bindTypeMap = array();
     if ($input_parameters) {
         $hasZeroIndex = array_key_exists(0, $input_parameters);
         foreach ($input_parameters as $key => $val) {
             if ($hasZeroIndex && is_numeric($key)) {
                 $this->bindValue($key + 1, $val);
             } else {
                 $this->bindValue($key, $val);
             }
         }
     }
     $ret = @oci_execute($this->sth, $this->conn->getExecuteMode());
     if (!$ret) {
         $error = oci_error($this->sth);
         throw new \Exception($error['message'], $error['code']);
     }
     return $ret;
 }
Пример #2
0
<?php

/*set the dir of mappers and entities*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
define("MAPPERS_DIR", "mappers");
define("ENTITIES_DIR", "entities");
require_once "Autoloader.php";
$db = new PdoAdapter();
$files = scandir(MAPPERS_DIR);
foreach ($files as $file) {
    $fullPath = MAPPERS_DIR . "/" . $file;
    if (is_file($fullPath)) {
        require_once $fullPath;
        echo "Mapper class found: " . getClass($fullPath) . "<br />", $class = getClass($fullPath);
        $tmp = new $class($db);
        $script = "CREATE TABLE " . $tmp->getDataSource() . " (";
        foreach ($tmp->getDbFields() as $key => $value) {
            $script .= $key . " " . $value["dbtype"];
            if (isset($value["primary"])) {
                $script .= " PRIMARY KEY";
            }
            if (isset($value["auto_increment"])) {
                $script .= " AUTO_INCREMENT";
            }
            $script .= ",";
        }
        $script = substr($script, 0, -1) . ");";
        //execute script
        $db->query($script);
        echo "Database script executed successfully.<br />";