|
| __construct () |
|
| nextId ($table_name) |
|
| createTable ($table_name, $fields) |
| experimental.... More...
|
|
| addPrimaryKey ($table_name, $primary_keys) |
|
| createSequence ($table_name) |
|
| tableExists ($table_name) |
|
| tableColumnExists ($table_name, $column_name) |
|
| addTableColumn ($table_name, $column_name, $attributes) |
|
| dropTable ($table_name) |
|
| query ($query) |
|
| fetchAll ($query_result) |
|
| dropSequence ($table_name) |
|
| dropTableColumn ($table_name, $column_name) |
|
| renameTableColumn ($table_name, $column_old_name, $column_new_name) |
|
| insert ($table_name, $values) |
|
| fetchObject ($query_result) |
|
| update ($table_name, $values, $where) |
|
| manipulate ($query) |
|
| fetchAssoc ($query_result) |
|
| numRows ($query_result) |
|
| quote ($value, $type) |
|
| addIndex ($table_name, $index_name) |
|
Definition at line 3 of file class.pdoDB.php.
◆ __construct()
Definition at line 26 of file class.pdoDB.php.
28 $this->pdo =
new PDO(
'mysql:host=localhost;dbname=test_db;charset=utf8',
'travis',
'');
29 $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
true);
30 $attr = PDO::MYSQL_ATTR_USE_BUFFERED_QUERY;
◆ addIndex()
pdoDB::addIndex |
( |
|
$table_name, |
|
|
|
$index_name |
|
) |
| |
◆ addPrimaryKey()
pdoDB::addPrimaryKey |
( |
|
$table_name, |
|
|
|
$primary_keys |
|
) |
| |
- Parameters
-
$table_name | string |
$primary_keys | array |
Definition at line 95 of file class.pdoDB.php.
References $keys.
97 $keys = implode($primary_keys);
98 $this->pdo->exec(
"ALTER TABLE $table_name ADD PRIMARY KEY ($keys)");
◆ addTableColumn()
pdoDB::addTableColumn |
( |
|
$table_name, |
|
|
|
$column_name, |
|
|
|
$attributes |
|
) |
| |
- Parameters
-
$table_name | string |
$column_name | string |
$attributes | array |
Definition at line 147 of file class.pdoDB.php.
References $attributes, array, and createTableFields().
151 $this->pdo->exec(
"ALTER TABLE $$table_name ADD $$col_str");
Create styles array
The data for the language used.
createTableFields($fields)
◆ createSequence()
pdoDB::createSequence |
( |
|
$table_name | ) |
|
◆ createTable()
pdoDB::createTable |
( |
|
$table_name, |
|
|
|
$fields |
|
) |
| |
◆ createTableFields()
pdoDB::createTableFields |
( |
|
$fields | ) |
|
|
protected |
- Parameters
-
- Returns
- string
Definition at line 75 of file class.pdoDB.php.
References $name, $query, and $type.
Referenced by addTableColumn(), and createTable().
78 foreach ($fields as
$name => $field) {
79 $type = $this->type_to_mysql_type[$field[
'type']];
80 $length = $field[
'length'];
81 $primary = isset($field[
'is_primary']) && $field[
'is_primary'] ?
"PRIMARY KEY" :
"";
82 $notnull = isset($field[
'is_notnull']) && $field[
'is_notnull'] ?
"NOT NULL" :
"";
83 $sequence = isset($field[
'sequence']) && $field[
'sequence'] ?
"AUTO_INCREMENT" :
"";
84 $query .=
"$name $type ($length) $sequence $primary $notnull,";
87 return substr(
$query, 0, -1);
◆ dropSequence()
pdoDB::dropSequence |
( |
|
$table_name | ) |
|
- Parameters
-
Definition at line 192 of file class.pdoDB.php.
References tableExists().
194 $table_seq = $table_name .
"_seq";
196 $this->pdo->exec(
"DROP TABLE $table_seq");
◆ dropTable()
pdoDB::dropTable |
( |
|
$table_name | ) |
|
- Parameters
-
Definition at line 158 of file class.pdoDB.php.
160 $this->pdo->exec(
"DROP TABLE $table_name");
◆ dropTableColumn()
pdoDB::dropTableColumn |
( |
|
$table_name, |
|
|
|
$column_name |
|
) |
| |
- Parameters
-
$table_name | string |
$column_name | string |
Definition at line 205 of file class.pdoDB.php.
207 $this->pdo->exec(
"ALTER TABLE $$table_name DROP COLUMN $column_name");
◆ fetchAll()
pdoDB::fetchAll |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- array
Definition at line 183 of file class.pdoDB.php.
185 return $query_result->fetchAll($query_result);
◆ fetchAssoc()
pdoDB::fetchAssoc |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- mixed
Definition at line 291 of file class.pdoDB.php.
References $res.
293 $res = $query_result->fetch(PDO::FETCH_ASSOC);
295 $query_result->closeCursor();
foreach($_POST as $key=> $value) $res
◆ fetchObject()
pdoDB::fetchObject |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- mixed|null
Definition at line 242 of file class.pdoDB.php.
References $res.
244 $res = $query_result->fetchObject();
246 $query_result->closeCursor();
foreach($_POST as $key=> $value) $res
◆ insert()
pdoDB::insert |
( |
|
$table_name, |
|
|
|
$values |
|
) |
| |
- Parameters
-
$table_name | string |
$values | |
Definition at line 226 of file class.pdoDB.php.
References array, and quote().
229 foreach ($values as $val) {
230 $real[] = $this->
quote($val[1], $val[0]);
232 $values = implode(
",", $real);
233 $this->pdo->exec(
"INSERT INTO $table_name VALUES ($values)");
Create styles array
The data for the language used.
◆ manipulate()
pdoDB::manipulate |
( |
|
$query | ) |
|
◆ nextId()
pdoDB::nextId |
( |
|
$table_name | ) |
|
- Parameters
-
- Returns
- int
Definition at line 39 of file class.pdoDB.php.
References $rows, and tableExists().
42 $table_seq = $table_name .
'_seq';
43 $stmt = $this->pdo->prepare(
"SELECT * FROM $table_seq");
45 $rows = $stmt->fetch(PDO::FETCH_ASSOC);
◆ numRows()
pdoDB::numRows |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- int
Definition at line 309 of file class.pdoDB.php.
311 return $query_result->rowCount();
◆ query()
- Parameters
-
- Returns
Definition at line 169 of file class.pdoDB.php.
References $query, and $res.
172 $err = $this->pdo->errorInfo();
foreach($_POST as $key=> $value) $res
◆ quote()
pdoDB::quote |
( |
|
$value, |
|
|
|
$type |
|
) |
| |
◆ renameTableColumn()
pdoDB::renameTableColumn |
( |
|
$table_name, |
|
|
|
$column_old_name, |
|
|
|
$column_new_name |
|
) |
| |
- Parameters
-
$table_name | string |
$column_old_name | string |
$column_new_name | string |
Definition at line 216 of file class.pdoDB.php.
218 $this->pdo->exec(
"alter table $table_name change $column_old_name $column_new_name");
◆ tableColumnExists()
pdoDB::tableColumnExists |
( |
|
$table_name, |
|
|
|
$column_name |
|
) |
| |
- Parameters
-
$table_name | string |
$column_name | string |
- Returns
- bool
Definition at line 133 of file class.pdoDB.php.
135 $statement = $this->pdo->query(
"SHOW COLUMNS FROM $table_name WHERE Field = '$column_name'");
136 $statement != null ? $statement->closeCursor() :
"";
138 return $statement != null && $statement->rowCount() != 0;
◆ tableExists()
pdoDB::tableExists |
( |
|
$table_name | ) |
|
◆ update()
pdoDB::update |
( |
|
$table_name, |
|
|
|
$values, |
|
|
|
$where |
|
) |
| |
- Parameters
-
$table_name | string |
$values | array |
$where | array |
Definition at line 260 of file class.pdoDB.php.
References $key, $query, and quote().
262 $query =
"UPDATE $table_name SET ";
263 foreach ($values as
$key => $val) {
264 $qval = $this->
quote($val[1], $val[0]);
268 foreach ($where as
$key => $val) {
269 $qval = $this->
quote($val[1], $val[0]);
◆ $pdo
◆ $staticPbo
◆ $type_to_mysql_type
pdoDB::$type_to_mysql_type |
|
protected |
Initial value: 'text' => 'VARCHAR',
'integer' => 'INT',
'float' => 'DOUBLE',
'date' => 'DATE',
'time' => 'TIME',
'datetime' => 'TIMESTAMP',
'clob' => 'LONGTEXT',
)
Definition at line 14 of file class.pdoDB.php.
The documentation for this class was generated from the following file: