示例#1
0
文件: Oracle.php 项目: cwcw/cms
 /**
  * Prepares and executes an SQL statement with bound data.
  *
  * @param mixed $sql  The SQL statement with placeholders.
  *                    May be a string or Zend_Db_Select.
  * @param mixed $bind An array of data to bind to the placeholders.
  * @return Zend_Db_Statement_Interface
  */
 public function query($sql, $bind = array())
 {
     if (is_array($bind)) {
         foreach ($bind as $name => $value) {
             if (!is_int($name) && ':' !== $name[0]) {
                 $newName = ":{$name}";
                 unset($bind[$name]);
                 $bind[$newName] = $value;
             }
         }
     }
     return parent::query($sql, $bind);
 }
示例#2
0
文件: Oracle.php 项目: rtsantos/mais
 /**
  * Executa o comando SQL dentro do Banco de Dados
  * 
  * @param string $sql
  * @param array $bind
  * @return bool 
  */
 public function query($sql, $bind = array())
 {
     if ($bind) {
         foreach ($bind as $name => &$value) {
             if ($value instanceof Protheus_Type_Date) {
                 $value = $value->getValueToDb();
             } else {
                 if ($value instanceof ZendT_Type_Date) {
                     if ($value->getType() == 'Date') {
                         $mask = 'YYYY-MM-DD';
                     } else {
                         $mask = 'YYYY-MM-DD HH24:MI';
                     }
                     $value = $value->getValueToDb();
                     $value = substr(str_replace('T', ' ', $value), 0, 19);
                     $sql = str_replace(':' . $name, "TO_DATE(:{$name},'{$mask}')", $sql);
                 }
             }
             /* elseif ($value instanceof ZendT_Type){
                $value = $value->getValueToDb();
                } */
         }
     }
     return parent::query($sql, $bind);
 }