18 $recordset = $this->dbInstance->query (
"SELECT \"TABLE\" as TABLE_NAME , \"to\" as COLUMN_NAME , \"from\" as REFERENCED_TABLE_SCHEMA FROM pragma_foreign_key_list('" . $tableName .
"') WHERE \"to\"='" . $pkName .
"';" );
19 return $recordset->fetchAll ( \PDO::FETCH_ASSOC );
23 $query = $this->dbInstance->query (
'SELECT name FROM sqlite_master WHERE type=\'table\';' );
24 return $query->fetchAll ( \PDO::FETCH_COLUMN );
28 $fieldkeys = array ();
29 $recordset = $this->dbInstance->query (
"PRAGMA TABLE_INFO(" . $tableName .
");" );
30 $keys = $recordset->fetchAll ( \PDO::FETCH_ASSOC );
31 foreach ( $keys as $key ) {
32 if ($key [
'pk'] == 1) {
33 $fieldkeys [] = $key [
'name'];
40 $fieldsInfos = array ();
41 $recordset = $this->dbInstance->query (
"PRAGMA TABLE_INFO(" . $tableName .
");" );
42 $fields = $recordset->fetchAll ( \PDO::FETCH_ASSOC );
43 foreach ( $fields as $field ) {
44 $fieldsInfos [$field [
'name']] = [
"Type" => $field [
'type'],
"Nullable" => $field [
"notnull"] ];
49 public function getRowNum(
string $tableName,
string $pkName,
string $condition): int {
50 $query = $this->dbInstance->query (
"SELECT num FROM (SELECT *,row_number() OVER (ORDER BY {$pkName}) AS num FROM \"{$tableName}\") x where " . $condition );
52 return $query->fetchColumn ( 0 );
57 public function groupConcat(
string $fields,
string $separator): string {
58 return
"GROUP_CONCAT({$fields},'{$separator}')";