/** * Introspects the database to get current index information for the specified table. * * @param string $table The name of the table to inspect. * @return array An array, where the values are hashes of MySQL index info. */ protected function indexInfoForTable($table) { $sql = "SHOW INDEX FROM `{$table}`"; $stmt = $this->connection()->query($sql); phpDataMapper::logQuery($sql); return $stmt ? $stmt->fetchAll() : false; }
/** * @see phpDataMapper_Adapter_Interface::dropDatabase() */ public function dropDatabase($database) { $sql = "DROP DATABASE " . $database; // Add query to log phpDataMapper::logQuery($sql); return $this->connection()->exec($sql); }
/** * Find records with custom SQL query * * @param string $sql SQL query to execute * @param array $binds Array of bound parameters to use as values for query * @throws phpDataMapper_Exception */ public function query($sql, array $binds = array()) { // Add query to log phpDataMapper::logQuery($sql, $binds); // Prepare and execute query if ($stmt = $this->adapter()->prepare($sql)) { $results = $stmt->execute($binds); if ($results) { $r = $this->getResultSet($stmt); } else { $r = false; } return $r; } else { throw new $this->_exceptionClass("Error: Unable to execute SQL query - failed to create" . " prepared statement from given SQL"); } }