|
| __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 25 of file class.pdoDB.php.
26 $this->pdo =
new PDO(
'mysql:host=localhost;dbname=test_db;charset=utf8',
'travis',
'');
27 $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
true);
28 $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 90 of file class.pdoDB.php.
91 $keys = implode($primary_keys);
92 $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 138 of file class.pdoDB.php.
References array, and createTableFields().
139 $col =
array( $column_name => $attributes );
141 $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 71 of file class.pdoDB.php.
References $query.
Referenced by addTableColumn(), and createTable().
73 foreach ($fields as $name => $field) {
74 $type = $this->type_to_mysql_type[$field[
'type']];
75 $length = $field[
'length'];
76 $primary = isset($field[
'is_primary']) && $field[
'is_primary'] ?
"PRIMARY KEY" :
"";
77 $notnull = isset($field[
'is_notnull']) && $field[
'is_notnull'] ?
"NOT NULL" :
"";
78 $sequence = isset($field[
'sequence']) && $field[
'sequence'] ?
"AUTO_INCREMENT" :
"";
79 $query .=
"$name $type ($length) $sequence $primary $notnull,";
82 return substr(
$query, 0, - 1);
◆ dropSequence()
pdoDB::dropSequence |
( |
|
$table_name | ) |
|
- Parameters
-
Definition at line 179 of file class.pdoDB.php.
References tableExists().
180 $table_seq = $table_name .
"_seq";
182 $this->pdo->exec(
"DROP TABLE $table_seq");
◆ dropTable()
pdoDB::dropTable |
( |
|
$table_name | ) |
|
- Parameters
-
Definition at line 148 of file class.pdoDB.php.
149 $this->pdo->exec(
"DROP TABLE $table_name");
◆ dropTableColumn()
pdoDB::dropTableColumn |
( |
|
$table_name, |
|
|
|
$column_name |
|
) |
| |
- Parameters
-
$table_name | string |
$column_name | string |
Definition at line 191 of file class.pdoDB.php.
192 $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 171 of file class.pdoDB.php.
172 return $query_result->fetchAll($query_result);
◆ fetchAssoc()
pdoDB::fetchAssoc |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- mixed
Definition at line 271 of file class.pdoDB.php.
References $res.
272 $res = $query_result->fetch(PDO::FETCH_ASSOC);
274 $query_result->closeCursor();
◆ fetchObject()
pdoDB::fetchObject |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- mixed|null
Definition at line 225 of file class.pdoDB.php.
References $res.
226 $res = $query_result->fetchObject();
228 $query_result->closeCursor();
◆ insert()
pdoDB::insert |
( |
|
$table_name, |
|
|
|
$values |
|
) |
| |
- Parameters
-
$table_name | string |
$values | |
Definition at line 210 of file class.pdoDB.php.
References array, and quote().
212 foreach ($values as $val) {
213 $real[] = $this->
quote($val[1], $val[0]);
215 $values = implode(
",", $real);
216 $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 37 of file class.pdoDB.php.
References tableExists().
39 $table_seq = $table_name .
'_seq';
40 $stmt = $this->pdo->prepare(
"SELECT * FROM $table_seq");
42 $rows = $stmt->fetch(PDO::FETCH_ASSOC);
45 return count($rows) ? 0 : $rows[
'seq'];
◆ numRows()
pdoDB::numRows |
( |
|
$query_result | ) |
|
- Parameters
-
$query_result | PDOStatement |
- Returns
- int
Definition at line 288 of file class.pdoDB.php.
289 return $query_result->rowCount();
◆ query()
◆ 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 201 of file class.pdoDB.php.
202 $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 125 of file class.pdoDB.php.
126 $statement = $this->pdo->query(
"SHOW COLUMNS FROM $table_name WHERE Field = '$column_name'");
127 $statement != NULL ? $statement->closeCursor() :
"";
129 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 242 of file class.pdoDB.php.
References $query, and quote().
243 $query =
"UPDATE $table_name SET ";
244 foreach ($values as $key => $val) {
245 $qval = $this->
quote($val[1], $val[0]);
249 foreach ($where as $key => $val) {
250 $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 13 of file class.pdoDB.php.
The documentation for this class was generated from the following file: