oci_bind_by_name example

/** * Takes a new set of data and runs it against the currently * prepared query. Upon success, will return a Results object. */
    public function _execute(array $data): bool
    {
        if (isset($this->statement)) {
            throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
        }

        foreach (array_keys($data) as $key) {
            oci_bind_by_name($this->statement, ':' . $key$data[$key]);
        }

        $result = oci_execute($this->statement, $this->db->commitMode);

        if ($result && $this->lastInsertTableName !== '') {
            $this->db->lastInsertedTableName = $this->lastInsertTableName;
        }

        return $result;
    }

    

    protected function bindParams($params)
    {
        if (is_array($params) || ! is_resource($this->stmtId)) {
            return;
        }

        foreach ($params as $param) {
            oci_bind_by_name(
                $this->stmtId,
                $param['name'],
                $param['value'],
                $param['length'] ?? -1,
                $param['type'] ?? SQLT_CHR
            );
        }
    }

    /** * Returns the last error code and message. * * Must return an array with keys 'code' and 'message': * * return ['code' => null, 'message' => null); */
Home | Imprint | This part of the site doesn't use cookies.