parent
a653043ce4
commit
8f7f0ae5c1
3 changed files with 39 additions and 20 deletions
37
build.sh
37
build.sh
|
|
@ -17,10 +17,16 @@ CFLAGS=" \
|
||||||
-DSQLITE_ENABLE_ICU \
|
-DSQLITE_ENABLE_ICU \
|
||||||
-DSQLITE_SOUNDEX \
|
-DSQLITE_SOUNDEX \
|
||||||
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
|
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
|
||||||
-I/usr/local/include"
|
-I. -I/usr/local/include"
|
||||||
|
|
||||||
LDFLAGS="-lcrypto -licuuc -licui18n -L/usr/local/lib"
|
LDFLAGS="-lcrypto -licuuc -licui18n -L/usr/local/lib"
|
||||||
|
|
||||||
|
# fix FreeBSD include
|
||||||
|
UNAME=$(uname)
|
||||||
|
if [ "x${UNAME}" = "xFreeBSD" ]; then
|
||||||
|
CFLAGS="${CFLAGS} -include /usr/include/sys/stat.h"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get PHP source code (installed version)
|
# Get PHP source code (installed version)
|
||||||
#
|
#
|
||||||
|
|
@ -126,21 +132,15 @@ fi
|
||||||
for FILE in "${BUILD_DIR}"/*
|
for FILE in "${BUILD_DIR}"/*
|
||||||
do
|
do
|
||||||
cat "${FILE}" | \
|
cat "${FILE}" | \
|
||||||
sed -e 's/<sqlite3.h>/"sqlcipher3.h"/g' | \
|
sed -e 's/sqlite/sqlcipher/g' | \
|
||||||
sed -e 's/pdo_sqlite/pdo_sqlcipher/g' | \
|
sed -e 's/SQLite/SQLCipher/g' | \
|
||||||
sed -e 's/php_sqlite3/php_sqlcipher/g' | \
|
sed -e 's/PDO_SQLITE/PDO_SQLCIPHER/g' > \
|
||||||
sed -e 's/sqlite_handle_/sqlcipher_handle_/g' | \
|
|
||||||
sed -e 's/sqlite_stmt_methods/sqlcipher_stmt_methods/g' | \
|
|
||||||
sed -e 's/PDO_SQLITE/PDO_SQLCIPHER/g' | \
|
|
||||||
sed -e 's/HEADER(sqlite)/HEADER(sqlcipher)/g' | \
|
|
||||||
sed -e 's/PDO Driver for SQLite 3.x/PDO Driver for SQLCipher/g' | \
|
|
||||||
sed -e 's/SQLite Library/SQLCipher Library/g' > \
|
|
||||||
"${FILE}.tmp"
|
"${FILE}.tmp"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_FILE=$(echo ${FILE} | sed 's/_sqlite/_sqlcipher/')
|
NEW_FILE=$(echo ${FILE} | sed 's/sqlite/sqlcipher/')
|
||||||
|
|
||||||
mv "${FILE}.tmp" "${NEW_FILE}"
|
mv "${FILE}.tmp" "${NEW_FILE}"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
@ -155,16 +155,15 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# copy unmodified sqlite sources
|
# magic for sqlite3 api sources
|
||||||
cp "${SQLCIPHER_SRC}/sqlite3.c" "${BUILD_DIR}/sqlcipher3.c"
|
cp "${SQLCIPHER_SRC}/sqlite3.c" "${BUILD_DIR}/sqlcipher3.c"
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "${SQLCIPHER_SRC}/sqlite3.h" "${BUILD_DIR}/sqlcipher3.h"
|
cp "${SQLCIPHER_SRC}/sqlite3.h" "${BUILD_DIR}/sqlcipher3.h"
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit $?
|
for FILE in "${BUILD_DIR}"/sqlcipher3.*
|
||||||
fi
|
do
|
||||||
|
sed -rie 's/sqlite3/sqlcipher3/g' "${FILE}"
|
||||||
|
sed -rie 's/(".*)sqlcipher3(.*")/\1sqlite3\2/g' "${FILE}"
|
||||||
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build pdo_sqlcipher
|
# Build pdo_sqlcipher
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ if test "$PHP_PDO_SQLCIPHER" != "no"; then
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT($pdo_inc_path)
|
AC_MSG_RESULT($pdo_inc_path)
|
||||||
|
|
||||||
php_pdo_sqlcipher_sources_core="pdo_sqlcipher.c sqlite_driver.c sqlite_statement.c sqlcipher3.c"
|
php_pdo_sqlcipher_sources_core="pdo_sqlcipher.c sqlcipher_driver.c sqlcipher_statement.c sqlcipher3.c"
|
||||||
|
|
||||||
PHP_NEW_EXTENSION(pdo_sqlcipher, $php_pdo_sqlcipher_sources_core, $ext_shared,,-I$pdo_inc_path)
|
PHP_NEW_EXTENSION(pdo_sqlcipher, $php_pdo_sqlcipher_sources_core, $ext_shared,,-I$pdo_inc_path)
|
||||||
|
|
||||||
|
|
|
||||||
20
example.php
20
example.php
|
|
@ -73,3 +73,23 @@ if ($result === false) {
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
print_r($row);
|
print_r($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// alter table
|
||||||
|
$sql = "ALTER TABLE `test` RENAME TO `test2`";
|
||||||
|
|
||||||
|
if ($pdo->exec($sql) === false) {
|
||||||
|
$error = $pdo->errorInfo();
|
||||||
|
die($error[0] . ": " . $error[2] . PHP_EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// select rows
|
||||||
|
$result = $pdo->query("SELECT * FROM `test2`");
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
$error = $pdo->errorInfo();
|
||||||
|
die($error[0] . ": " . $error[2] . PHP_EOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($result as $row) {
|
||||||
|
print_r($row);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue