/** * {@inheritdoc} */ public function bindValue($param, $value, $type = null) { if ($type) { if (isset(self::$_paramTypeMap[$type])) { $type = self::$_paramTypeMap[$type]; } else { throw new Exception("Unknown type: '{$type}'"); } return $this->_stmt->bindValue($param, $value, $type); } return $this->_stmt->bindValue($param, $value); }
/** * Move a cell object from one address to another * * @param string $fromAddress Current address of the cell to move * @param string $toAddress Destination address of the cell to move * @return boolean */ public function moveCell($fromAddress, $toAddress) { if ($fromAddress === $this->_currentObjectID) { $this->_currentObjectID = $toAddress; } $this->_deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT); $result = $this->_deleteQuery->execute(); if ($result === false) { throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); } $this->_updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT); $this->_updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT); $result = $this->_updateQuery->execute(); if ($result === false) { throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); } return TRUE; }
/** * @param int $id * @param array $data * @param callable $callback * * @throws \Exception */ public function import(&$id, array $data, callable $callback) { foreach ($data as $uid => $elem) { $valuesFullText = $this->valuesFullText($elem); $valuesFilter = $this->valuesFilter($elem); if (sizeof($valuesFullText) > 0) { $json = json_encode($elem); $num = 1; $this->stmtInsertFilter->bindValue($num++, $id, SQLITE3_INTEGER); if ($this->useuid) { $this->stmtInsertFilter->bindValue($num++, $uid, SQLITE3_TEXT); } $this->stmtInsertFilter->bindValue($num++, $json, SQLITE3_TEXT); foreach ($valuesFilter as $valueFilter) { $this->stmtInsertFilter->bindValue($num++, $valueFilter); } if (@$this->stmtInsertFilter->execute() === false) { $lasterror = $this->db->lastErrorCode(); if ($lasterror != self::SQLITE_ERROR_CODE_CONSTRAINT) { $this->output->writeln($lasterror . " : " . $this->db->lastErrorMsg()); throw new \Exception("cannot insert filter fields"); } else { @$this->stmtInsertFilter->reset(); continue; } } $num = 1; $this->stmtInsertFullText->bindValue($num++, $id, SQLITE3_INTEGER); foreach ($valuesFullText as $valueFullText) { $this->stmtInsertFullText->bindValue($num++, $valueFullText, SQLITE3_TEXT); } if ($this->stmtInsertFullText->execute() === false) { $this->output->writeln($this->db->lastErrorCode() . " : " . $this->db->lastErrorMsg()); throw new \Exception("cannot insert full text fields"); } $id++; } $callback(); } }
public function remoteHasDone($task) { switch ($task->action) { case self::CMD_PUT: $this->_prepRemoteHasUploaded->bindValue(":path", $task->path); $this->_prepRemoteHasUploaded->execute(); break; case self::CMD_DELETE: $this->_prepRemoteHasDeleted->bindValue(":path", $task->path); $this->_prepRemoteHasDeleted->execute(); break; case self::CMD_MKDIR: $this->_prepRemoteHasUploaded->bindValue(":path", $task->path); $this->_prepRemoteHasUploaded->execute(); break; case self::CMD_TS: $this->_prepRemoteHasUploaded->bindValue(":path", $task->path); $this->_prepRemoteHasUploaded->execute(); break; default: $this->_out->logError("ignored command {$task->action}"); } }
/** * Binds fulltext parameters to a prepared statement as this happens in multiple places. * * @param \SQLite3Stmt $preparedStatement * @param $fulltext */ protected function bindFulltextParametersToStatement(\SQLite3Stmt $preparedStatement, $fulltext) { $preparedStatement->bindValue(':h1', isset($fulltext['h1']) ? $fulltext['h1'] : ''); $preparedStatement->bindValue(':h2', isset($fulltext['h2']) ? $fulltext['h2'] : ''); $preparedStatement->bindValue(':h3', isset($fulltext['h3']) ? $fulltext['h3'] : ''); $preparedStatement->bindValue(':h4', isset($fulltext['h4']) ? $fulltext['h4'] : ''); $preparedStatement->bindValue(':h5', isset($fulltext['h5']) ? $fulltext['h5'] : ''); $preparedStatement->bindValue(':h6', isset($fulltext['h6']) ? $fulltext['h6'] : ''); $preparedStatement->bindValue(':text', isset($fulltext['text']) ? $fulltext['text'] : ''); }
public static function stmtBind(SQLite3Stmt &$stmt, array $values) { SystemEvent::raise(SystemEvent::DEBUG, 'Binding.', __METHOD__); // // F**k support for SQLite3 BLOB // for ($i = 0; $i < count($values); $i++) { $type = SQLITE3_TEXT; if (is_null($values[$i])) { $type = SQLITE3_NULL; } elseif (is_int($values[$i])) { $type = SQLITE3_INTEGER; } elseif (is_float($values[$i])) { $type = SQLITE3_FLOAT; } if (!$stmt->bindValue(':' . $i, $values[$i], $type)) { return false; } } }