Doctrine 1.2.4
Doctrine_Search_File Class Reference

Inherits Doctrine_Search.

Public Member Functions

 __construct (array $options=array())
 
 __get ($option)
 
 __isset ($option)
 
 __set ($name, $value)
 
 __unset ($name)
 
 actAs ($tpl, array $options=array())
 
 add ($value)
 
 addChild ($generator)
 
 addListener ($listener, $name=null)
 
 analyze ($text, $encoding=null)
 
 attribute ($attr, $value)
 
 batchUpdateIndex ($limit=null, $offset=null, $encoding=null)
 
 bind ($name, $resource)
 
 bindQueryParts (array $queryParts)
 
 buildChildDefinitions ()
 
 buildForeignKeys (Doctrine_Table $table)
 
 buildForeignRelation ($alias=null)
 
 buildLocalRelation ($alias=null)
 
 check ($constraint, $name=null)
 
 contains ($offset)
 
 generateClass (array $definition=array())
 
 generateClassFromTable (Doctrine_Table $table)
 
 get ($offset)
 
 getListener ()
 
 getLocator ()
 
 getOption ($name)
 
 getOptions ()
 
 getRelationForeignKey ()
 
 getRelationLocalKey ()
 
 getTable ()
 
 hasColumn ($name, $type=null, $length=null, $options=array())
 
 hasColumns (array $definitions)
 
 hasMany ()
 
 hasOne ()
 
 index ($name, array $definition=array())
 
 indexDirectory ($dir)
 
 initialize (Doctrine_Table $table)
 
 initOptions ()
 
 locate ($name)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 option ($name, $value=null)
 
 ownerHasMany ($name, $options)
 
 ownerHasOne ($name, $options)
 
 readTableData ($limit=null, $offset=null)
 
 remove ($offset)
 
 search ($string, $query=null)
 
 set ($offset, $value)
 
 setArray (array $array)
 
 setColumnOption ($columnName, $option, $value)
 
 setColumnOptions ($name, array $options)
 
 setListener ($listener)
 
 setLocator (Doctrine_Locator $locator)
 
 setOption ($name, $value)
 
 setTableDefinition ()
 
 unique ($fields, $options=array(), $createUniqueIndex=true)
 
 updateIndex (array $data, $encoding=null)
 

Static Public Member Functions

static getNullObject ()
 
static initNullObject (Doctrine_Null $null)
 

Protected Attributes

 $_initialized = false
 
 $_table
 

Detailed Description

Definition at line 33 of file File.php.

Constructor & Destructor Documentation

Doctrine_Search_File::__construct ( array  $options = array())

constructor

Parameters
array$optionsan array of plugin options

Definition at line 40 of file File.php.

{
parent::__construct($options);
if ( ! isset($this->_options['resource'])) {
$tableClass = $conn->getAttribute(Doctrine_Core::ATTR_TABLE_CLASS);
$table = new $tableClass('File', $conn);
$table->setColumn('url', 'string', 255, array('primary' => true));
}
if (empty($this->_options['fields'])) {
$this->_options['fields'] = array('url', 'content');
}
$this->initialize($table);
}

Member Function Documentation

Doctrine_Record_Generator::__get (   $option)
inherited

An alias for getOption

Parameters
string$option

Definition at line 64 of file Generator.php.

{
if (isset($this->_options[$option])) {
return $this->_options[$option];
}
return null;
}
Doctrine_Record_Generator::__isset (   $option)
inherited

__isset

Parameters
string$option

Definition at line 77 of file Generator.php.

{
return isset($this->_options[$option]);
}
Doctrine_Access::__set (   $name,
  $value 
)
inherited

Set key and value to data

See Also
set, offsetSet
Parameters
$name
$value
Returns
void

Definition at line 58 of file Access.php.

{
$this->set($name, $value);
}
Doctrine_Access::__unset (   $name)
inherited

Remove key from data

Parameters
string$name
Returns
void

Definition at line 92 of file Access.php.

{
return $this->remove($name);
}
Doctrine_Record_Abstract::actAs (   $tpl,
array  $options = array() 
)
inherited

Loads the given plugin.

This method loads a behavior in the record. It will add the behavior also to the record table if it. It is tipically called in

See Also
setUp().
Parameters
mixed$tplif an object, must be a subclass of Doctrine_Template. If a string, Doctrine will try to instantiate an object of the classes Doctrine_Template_$tpl and subsequently $tpl, using also autoloading capabilities if defined.
array$optionsargument to pass to the template constructor if $tpl is a class name
Exceptions
Doctrine_Record_Exceptionif $tpl is neither an instance of Doctrine_Template subclass or a valid class name, that could be instantiated.
Returns
Doctrine_Record this object; provides a fluent interface.

Definition at line 349 of file Abstract.php.

{
if ( ! is_object($tpl)) {
$className = 'Doctrine_Template_' . $tpl;
if (class_exists($className, true)) {
$tpl = new $className($options);
} else if (class_exists($tpl, true)) {
$tpl = new $tpl($options);
} else {
throw new Doctrine_Record_Exception('Could not load behavior named: "' . $tpl . '"');
}
}
if ( ! ($tpl instanceof Doctrine_Template)) {
throw new Doctrine_Record_Exception('Loaded behavior class is not an instance of Doctrine_Template.');
}
$className = get_class($tpl);
$this->_table->addTemplate($className, $tpl);
$tpl->setInvoker($this);
$tpl->setTable($this->_table);
$tpl->setUp();
$tpl->setTableDefinition();
return $this;
}
Doctrine_Access::add (   $value)
inherited

Add the value

Parameters
mixed$valueThe value to add
Returns
void

Definition at line 199 of file Access.php.

{
throw new Doctrine_Exception('Add is not supported for ' . get_class($this));
}
Doctrine_Record_Generator::addChild (   $generator)
inherited

Add child record generator

Parameters
Doctrine_Record_Generator$generator
Returns
void

Definition at line 117 of file Generator.php.

{
$this->_options['children'][] = $generator;
}
Doctrine_Record_Abstract::addListener (   $listener,
  $name = null 
)
inherited

addListener

Parameters
Doctrine_EventListener_Interface | Doctrine_Overloadable$listener
Returns
Doctrine_Record

Definition at line 67 of file Abstract.php.

{
$this->_table->addRecordListener($listener, $name);
return $this;
}
Doctrine_Search::analyze (   $text,
  $encoding = null 
)
inherited

analyze a text in the encoding format

Parameters
string$text
string$encoding
Returns
void

Definition at line 123 of file Search.php.

{
return $this->_options['analyzer']->analyze($text, $encoding);
}
Doctrine_Record_Abstract::attribute (   $attr,
  $value 
)
inherited

attribute sets or retrieves an option

See Also
Doctrine_Core::ATTR_* constants availible attributes
Parameters
mixed$attr
mixed$value
Returns
mixed

Definition at line 182 of file Abstract.php.

{
if ($value == null) {
if (is_array($attr)) {
foreach ($attr as $k => $v) {
$this->_table->setAttribute($k, $v);
}
} else {
return $this->_table->getAttribute($attr);
}
} else {
$this->_table->setAttribute($attr, $value);
}
}
Doctrine_Search::batchUpdateIndex (   $limit = null,
  $offset = null,
  $encoding = null 
)
inherited

batchUpdateIndex

Parameters
mixed$limit
mixed$offset
Returns
void

Definition at line 221 of file Search.php.

{
$table = $this->_options['table'];
$this->initialize($table);
$id = $table->getIdentifierColumnNames();
$class = $this->_options['className'];
$fields = $this->_options['fields'];
$conn = $this->_options['table']->getConnection();
for ($i = 0; $i < count($fields); $i++) {
$fields[$i] = $table->getColumnName($fields[$i], $fields[$i]);
}
$rows = $this->readTableData($limit, $offset);
$ids = array();
foreach ($rows as $row) {
foreach ($id as $idcol) {
$ids[] = $row[$idcol];
}
}
if (count($ids) > 0)
{
$sql = 'DELETE FROM ' . $conn->quoteIdentifier($this->_table->getTableName());
if (count($id) == 1) {
$placeholders = str_repeat('?, ', count($ids));
$placeholders = substr($placeholders, 0, strlen($placeholders) - 2);
$sql .= ' WHERE ' . $conn->quoteIdentifier($table->getIdentifier()) . ' IN (' . substr($placeholders, 0) . ')';
} else {
// composite primary key
$placeholders = '';
foreach ($table->getIdentifier() as $id) {
$placeholders .= $conn->quoteIdentifier($id) . ' = ? AND ';
}
$placeholders = '(' . substr($placeholders, 0, strlen($placeholders) - 5) . ') OR ';
$placeholders = str_repeat($placeholders, count($rows));
$placeholders = substr($placeholders, 0, strlen($placeholders) - 4);
$sql .= ' WHERE ' . $placeholders;
}
$conn->exec($sql, $ids);
}
foreach ($rows as $row) {
$conn->beginTransaction();
try {
foreach ($fields as $field) {
$data = $row[$field];
$terms = $this->analyze($data, $encoding);
foreach ($terms as $pos => $term) {
$index = new $class();
$index->keyword = $term;
$index->position = $pos;
$index->field = $field;
foreach ((array) $table->getIdentifier() as $identifier) {
$index->$identifier = $row[$table->getColumnName($identifier, $identifier)];
}
$index->save();
$index->free(true);
}
}
$conn->commit();
} catch (Doctrine_Exception $e) {
$conn->rollback();
throw $e;
}
}
}
Doctrine_Locator_Injectable::bind (   $name,
  $resource 
)
inherited

bind binds a resource to a name

Parameters
string$namethe name of the resource to bind
mixed$valuethe value of the resource
Returns
Doctrine_Locator this object

Definition at line 120 of file Injectable.php.

{
$this->_resources[$name] = $resource;
return $this;
}
Doctrine_Record_Abstract::bindQueryParts ( array  $queryParts)
inherited

bindQueryParts binds query parts to given component

Parameters
array$queryPartsan array of pre-bound query parts
Returns
Doctrine_Record this object

Definition at line 322 of file Abstract.php.

{
$this->_table->bindQueryParts($queryParts);
return $this;
}
Doctrine_Record_Generator::buildChildDefinitions ( )
inherited

Build the child behavior definitions that are attached to this generator

Returns
void

Definition at line 246 of file Generator.php.

{
if ( ! isset($this->_options['children'])) {
throw new Doctrine_Record_Exception("Unknown option 'children'.");
}
foreach ($this->_options['children'] as $child) {
if ($child instanceof Doctrine_Template) {
if ($child->getPlugin() !== null) {
$this->_table->addGenerator($child->getPlugin(), get_class($child->getPlugin()));
}
$this->_table->addTemplate(get_class($child), $child);
$child->setInvoker($this);
$child->setTable($this->_table);
$child->setTableDefinition();
$child->setUp();
} else {
$this->_table->addGenerator($child, get_class($child));
$child->initialize($this->_table);
}
}
}
Doctrine_Record_Generator::buildForeignKeys ( Doctrine_Table  $table)
inherited

Generates foreign keys for the plugin table based on the owner table. These columns are automatically added to the generated model so we can create foreign keys back to the table object that owns the plugin.

Parameters
Doctrine_Table$tablethe table object that owns the plugin
Returns
array an array of foreign key definitions

Definition at line 279 of file Generator.php.

{
$fk = array();
foreach ((array) $table->getIdentifier() as $column) {
$def = $table->getDefinitionOf($column);
unset($def['autoincrement']);
unset($def['sequence']);
unset($def['primary']);
$col = $column;
$def['primary'] = true;
$fk[$col] = $def;
}
return $fk;
}
Doctrine_Record_Generator::buildForeignRelation (   $alias = null)
inherited

Build the foreign relationship on the invoking table in $this->_options['table'] which points back to the model generated in this generator instance.

Parameters
string$aliasAlias of the foreign relation
Returns
void

Definition at line 358 of file Generator.php.

{
$options = array(
'local' => $this->getRelationForeignKey(),
'foreign' => $this->getRelationLocalKey(),
'localKey' => false
);
if (isset($this->_options['cascadeDelete']) && $this->_options['cascadeDelete'] && $this->_options['appLevelDelete']) {
$options['cascade'] = array('delete');
}
$aliasStr = '';
if ($alias !== null) {
$aliasStr = ' as ' . $alias;
}
$this->ownerHasMany($this->_table->getComponentName() . $aliasStr, $options);
}
Doctrine_Record_Generator::buildLocalRelation (   $alias = null)
inherited

Build the local relationship on the generated model for this generator instance which points to the invoking table in $this->_options['table']

Parameters
string$aliasAlias of the foreign relation
Returns
void

Definition at line 305 of file Generator.php.

{
$options = array(
'local' => $this->getRelationLocalKey(),
'foreign' => $this->getRelationForeignKey(),
'owningSide' => true
);
if (isset($this->_options['cascadeDelete']) && $this->_options['cascadeDelete'] && ! $this->_options['appLevelDelete']) {
$options['onDelete'] = 'CASCADE';
$options['onUpdate'] = 'CASCADE';
}
$aliasStr = '';
if ($alias !== null) {
$aliasStr = ' as ' . $alias;
}
$this->hasOne($this->_options['table']->getComponentName() . $aliasStr, $options);
}
Doctrine_Record_Abstract::check (   $constraint,
  $name = null 
)
inherited

Adds a check constraint.

This method will add a CHECK constraint to the record table.

Parameters
mixed$constrainteither a SQL constraint portion or an array of CHECK constraints. If array, all values will be added as constraint
string$nameoptional constraint name. Not used if $constraint is an array.
Returns
Doctrine_Record this object

Definition at line 388 of file Abstract.php.

{
if (is_array($constraint)) {
foreach ($constraint as $name => $def) {
$this->_table->addCheckConstraint($def, $name);
}
} else {
$this->_table->addCheckConstraint($constraint, $name);
}
return $this;
}
Doctrine_Access::contains (   $offset)
inherited

Check if the specified offset exists

Parameters
mixed$offsetThe offset to check
Returns
boolean True if exists otherwise false

Definition at line 188 of file Access.php.

{
throw new Doctrine_Exception('Contains is not supported for ' . get_class($this));
}
Doctrine_Record_Generator::generateClass ( array  $definition = array())
inherited

Generates the class definition for plugin class

Parameters
array$definitionDefinition array defining columns, relations and options for the model
Returns
void

Definition at line 445 of file Generator.php.

{
$definition['className'] = $this->_options['className'];
$definition['toString'] = isset($this->_options['toString']) ? $this->_options['toString'] : false;
if (isset($this->_options['listeners'])) {
$definition['listeners'] = $this->_options['listeners'];
}
$builder = new Doctrine_Import_Builder();
$builderOptions = isset($this->_options['builderOptions']) ? (array) $this->_options['builderOptions']:array();
$builder->setOptions($builderOptions);
if ($this->_options['generateFiles']) {
if (isset($this->_options['generatePath']) && $this->_options['generatePath']) {
$builder->setTargetPath($this->_options['generatePath']);
$builder->buildRecord($definition);
} else {
throw new Doctrine_Record_Exception('If you wish to generate files then you must specify the path to generate the files in.');
}
} else {
$def = $builder->buildDefinition($definition);
eval($def);
}
}
Doctrine_Record_Generator::generateClassFromTable ( Doctrine_Table  $table)
inherited

Generate a Doctrine_Record from a populated Doctrine_Table instance

Parameters
Doctrine_Table$table
Returns
void

Definition at line 428 of file Generator.php.

{
$definition = array();
$definition['columns'] = $table->getColumns();
$definition['tableName'] = $table->getTableName();
$definition['actAs'] = $table->getTemplates();
return $this->generateClass($definition);
}
Doctrine_Access::get (   $offset)
inherited

Return the element with the specified offset

Parameters
mixed$offsetThe offset to return
Returns
mixed

Definition at line 165 of file Access.php.

{
throw new Doctrine_Exception('Get is not supported for ' . get_class($this));
}
Doctrine_Record_Abstract::getListener ( )
inherited

getListener

Returns
Doctrine_EventListener_Interface|Doctrine_Overloadable

Definition at line 79 of file Abstract.php.

{
return $this->_table->getRecordListener();
}
Doctrine_Locator_Injectable::getLocator ( )
inherited

getLocator returns the locator associated with this object

if there are no locator locally associated then this method tries to fetch the current global locator

Returns
Doctrine_Locator

Definition at line 75 of file Injectable.php.

{
if ( ! isset($this->_locator)) {
$this->_locator = Doctrine_Locator::instance();
}
return $this->_locator;
}
static Doctrine_Locator_Injectable::getNullObject ( )
staticinherited

getNullObject returns the null object associated with this object

Returns
Doctrine_Null

Definition at line 145 of file Injectable.php.

{
return self::$_null;
}
Doctrine_Record_Generator::getOption (   $name)
inherited

Returns the value of an option

Parameters
$optionthe name of the option to retrieve
Returns
mixed the value of the option

Definition at line 88 of file Generator.php.

{
if ( ! isset($this->_options[$name])) {
throw new Doctrine_Exception('Unknown option ' . $name);
}
return $this->_options[$name];
}
Doctrine_Record_Generator::getOptions ( )
inherited

Returns all options and their associated values

Returns
array all options as an associative array

Definition at line 127 of file Generator.php.

{
return $this->_options;
}
Doctrine_Record_Generator::getRelationForeignKey ( )
inherited

Get the foreign key of the generated relationship

Returns
string $foreign

Definition at line 394 of file Generator.php.

{
$table = $this->_options['table'];
$identifier = $table->getIdentifier();
foreach ((array) $identifier as $column) {
$def = $table->getDefinitionOf($column);
if (isset($def['primary']) && $def['primary'] && isset($def['autoincrement']) && $def['autoincrement']) {
return $column;
}
}
return $identifier;
}
Doctrine_Record_Generator::getRelationLocalKey ( )
inherited

Get the local key of the generated relationship

Returns
string $local

Definition at line 384 of file Generator.php.

{
return $this->getRelationForeignKey();
}
Doctrine_Record_Abstract::getTable ( )
inherited

getTable returns the associated table object

Returns
Doctrine_Table the associated table object

Definition at line 56 of file Abstract.php.

{
return $this->_table;
}
Doctrine_Record_Abstract::hasColumn (   $name,
  $type = null,
  $length = null,
  $options = array() 
)
inherited

Sets a column definition

Parameters
string$name
string$type
integer$length
mixed$options
Returns
void

Definition at line 260 of file Abstract.php.

{
$this->_table->setColumn($name, $type, $length, $options);
}
Doctrine_Record_Abstract::hasColumns ( array  $definitions)
inherited

Set multiple column definitions at once

Parameters
array$definitions
Returns
void

Definition at line 271 of file Abstract.php.

{
foreach ($definitions as $name => $options) {
$length = isset($options['length']) ? $options['length']:null;
$this->hasColumn($name, $options['type'], $length, $options);
}
}
Doctrine_Record_Abstract::hasMany ( )
inherited

Binds One-to-Many / Many-to-Many aggregate relation

Parameters
string$componentNamethe name of the related component
string$optionsrelation options
See Also
Doctrine_Relation::_$definition
Returns
Doctrine_Record this object

Definition at line 244 of file Abstract.php.

{
$this->_table->bind(func_get_args(), Doctrine_Relation::MANY);
return $this;
}
Doctrine_Record_Abstract::hasOne ( )
inherited

Binds One-to-One aggregate relation

Parameters
string$componentNamethe name of the related component
string$optionsrelation options
See Also
Doctrine_Relation::_$definition
Returns
Doctrine_Record this object

Definition at line 229 of file Abstract.php.

{
$this->_table->bind(func_get_args(), Doctrine_Relation::ONE);
return $this;
}
Doctrine_Record_Abstract::index (   $name,
array  $definition = array() 
)
inherited

index defines or retrieves an index if the second parameter is set this method defines an index if not this method retrieves index named $name

Parameters
string$namethe name of the index
array$definitionthe definition array
Returns
mixed

Definition at line 107 of file Abstract.php.

{
if ( ! $definition) {
return $this->_table->getIndex($name);
} else {
return $this->_table->addIndex($name, $definition);
}
}
Doctrine_Search_File::indexDirectory (   $dir)

indexes given directory

Parameters
string$dirthe name of the directory to index
Returns
void

Definition at line 70 of file File.php.

{
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($it as $file) {
if (strpos($file, DIRECTORY_SEPARATOR . '.svn') !== false) {
continue;
}
$this->updateIndex(array('url' => $file->getPathName(),
'content' => file_get_contents($file)));
}
}
Doctrine_Record_Generator::initialize ( Doctrine_Table  $table)
inherited

Initialize the plugin. Call in Doctrine_Template setTableDefinition() in order to initiate a generator in a template

See Also
Doctrine_Template_I18n
Parameters
Doctrine_Table$table
Returns
void

Definition at line 139 of file Generator.php.

{
if ($this->_initialized) {
return false;
}
$this->_initialized = true;
$this->initOptions();
$table->addGenerator($this, get_class($this));
$this->_options['table'] = $table;
$ownerClassName = $this->_options['table']->getComponentName();
$className = $this->_options['className'];
$this->_options['className'] = str_replace('%CLASS%', $ownerClassName, $className);
if (isset($this->_options['tableName'])) {
$ownerTableName = $this->_options['table']->getTableName();
$tableName = $this->_options['tableName'];
$this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName);
}
// check that class doesn't exist (otherwise we cannot create it)
if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'])) {
$this->_table = Doctrine_Core::getTable($this->_options['className']);
return false;
}
$this->buildTable();
$fk = $this->buildForeignKeys($this->_options['table']);
$this->_table->setColumns($fk);
$this->buildRelation();
$this->setTableDefinition();
$this->setUp();
$this->generateClassFromTable($this->_table);
$this->_table->initIdentifier();
}
static Doctrine_Locator_Injectable::initNullObject ( Doctrine_Null  $null)
staticinherited

initNullObject initializes the null object

Parameters
Doctrine_Null$null
Returns
void

Definition at line 134 of file Injectable.php.

{
self::$_null = $null;
}
Doctrine_Record_Generator::initOptions ( )
inherited

Empty template method for providing the concrete plugins the ability to initialize options before the actual definition is being built

Returns
void

Definition at line 236 of file Generator.php.

{
}
Doctrine_Locator_Injectable::locate (   $name)
inherited

locate locates a resource by given name and returns it

if the resource cannot be found locally this method tries to use the global locator for finding the resource

See Also
Doctrine_Locator::locate()
Exceptions
Doctrine_Locator_Exceptionif the resource could not be found
Parameters
string$namethe name of the resource
Returns
mixed the located resource

Definition at line 96 of file Injectable.php.

{
if (isset($this->_resources[$name])) {
if (is_object($this->_resources[$name])) {
return $this->_resources[$name];
} else {
// get the name of the concrete implementation
$concreteImpl = $this->_resources[$name];
return $this->getLocator()->locate($concreteImpl);
}
} else {
return $this->getLocator()->locate($name);
}
}
Doctrine_Access::offsetExists (   $offset)
inherited

Check if an offset axists

Parameters
mixed$offset
Returns
boolean Whether or not this object contains $offset

Definition at line 103 of file Access.php.

{
return $this->contains($offset);
}
Doctrine_Access::offsetGet (   $offset)
inherited

An alias of get()

See Also
get, __get
Parameters
mixed$offset
Returns
mixed

Definition at line 115 of file Access.php.

{
return $this->get($offset);
}
Doctrine_Access::offsetSet (   $offset,
  $value 
)
inherited

Sets $offset to $value

See Also
set, __set
Parameters
mixed$offset
mixed$value
Returns
void

Definition at line 128 of file Access.php.

{
if ( ! isset($offset)) {
$this->add($value);
} else {
$this->set($offset, $value);
}
}
Doctrine_Access::offsetUnset (   $offset)
inherited

Unset a given offset

See Also
set, offsetSet, __set
Parameters
mixed$offset

Definition at line 143 of file Access.php.

{
return $this->remove($offset);
}
Doctrine_Record_Abstract::option (   $name,
  $value = null 
)
inherited

option sets or retrieves an option

See Also
Doctrine_Table::$options availible options
Parameters
mixed$namethe name of the option
mixed$valueoptions value
Returns
mixed

Definition at line 206 of file Abstract.php.

{
if ($value === null) {
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->_table->setOption($k, $v);
}
} else {
return $this->_table->getOption($name);
}
} else {
$this->_table->setOption($name, $value);
}
}
Doctrine_Record_Generator::ownerHasMany (   $name,
  $options 
)
inherited

Add a Doctrine_Relation::MANY relationship to the generator owner table

Parameters
string$name
array$options
Returns
void

Definition at line 334 of file Generator.php.

{
$this->_options['table']->hasMany($name, $options);
}
Doctrine_Record_Generator::ownerHasOne (   $name,
  $options 
)
inherited

Add a Doctrine_Relation::ONE relationship to the generator owner table

Parameters
string$name
array$options
Returns
void

Definition at line 346 of file Generator.php.

{
$this->_options['table']->hasOne($name, $options);
}
Doctrine_Search::readTableData (   $limit = null,
  $offset = null 
)
inherited

readTableData

Parameters
mixed$limit
mixed$offset
Returns
Doctrine_Collection The collection of results

Definition at line 192 of file Search.php.

{
$this->initialize($this->_options['table']);
$conn = $this->_options['table']->getConnection();
$tableName = $this->_options['table']->getTableName();
$id = current($this->_options['table']->getIdentifierColumnNames());
$tableId = current($this->_table->getIdentifierColumnNames());
$query = 'SELECT * FROM ' . $conn->quoteIdentifier($tableName)
. ' WHERE ' . $conn->quoteIdentifier($id)
. ' IN (SELECT ' . $conn->quoteIdentifier($tableId)
. ' FROM ' . $conn->quoteIdentifier($this->_table->getTableName())
. ' WHERE keyword = \'\') OR ' . $conn->quoteIdentifier($id)
. ' NOT IN (SELECT ' . $conn->quoteIdentifier($tableId)
. ' FROM ' . $conn->quoteIdentifier($this->_table->getTableName()) . ')';
$query = $conn->modifyLimitQuery($query, $limit, $offset);
return $conn->fetchAll($query);
}
Doctrine_Access::remove (   $offset)
inherited

Remove the element with the specified offset

Parameters
mixed$offsetThe offset to remove
Returns
boolean True if removed otherwise false

Definition at line 154 of file Access.php.

{
throw new Doctrine_Exception('Remove is not supported for ' . get_class($this));
}
Doctrine_Search::search (   $string,
  $query = null 
)
inherited

Searchable keyword search

Parameters
string$stringKeyword string to search for
Doctrine_Query$queryQuery object to alter. Adds where condition to limit the results using the search index
Returns
array ids and relevancy

Definition at line 94 of file Search.php.

{
$q = new Doctrine_Search_Query($this->_table);
if ($query instanceof Doctrine_Query) {
$q->query($string, false);
$newQuery = $query->copy();
$query->getSqlQuery();
$key = (array) $this->getOption('table')->getIdentifier();
$newQuery->addWhere($query->getRootAlias() . '.'.current($key).' IN (SQL:' . $q->getSqlQuery() . ')', $q->getParams());
return $newQuery;
} else {
if ( ! isset($this->_options['connection'])) {
$this->_options['connection'] = $this->_table->getConnection();
}
$q->query($string);
return $this->_options['connection']->fetchAll($q->getSqlQuery(), $q->getParams());
}
}
Doctrine_Access::set (   $offset,
  $value 
)
inherited

Set the offset to the value

Parameters
mixed$offsetThe offset to set
mixed$valueThe value to set the offset to

Definition at line 177 of file Access.php.

{
throw new Doctrine_Exception('Set is not supported for ' . get_class($this));
}
Doctrine_Access::setArray ( array  $array)
inherited

Set an entire aray to the data

Parameters
array$arrayAn array of key => value pairs
Returns
Doctrine_Access

Definition at line 41 of file Access.php.

{
foreach ($array as $k => $v) {
$this->set($k, $v);
}
return $this;
}
Doctrine_Record_Abstract::setColumnOption (   $columnName,
  $option,
  $value 
)
inherited

Set an individual column option

Parameters
string$columnName
string$option
string$value
Returns
void

Definition at line 310 of file Abstract.php.

{
$this->_table->setColumnOption($columnName, $option, $value);
}
Doctrine_Record_Abstract::setColumnOptions (   $name,
array  $options 
)
inherited

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

[php]
public function setTableDefinition()
{
    parent::setTableDefinition();
    $this->setColumnOptions('username', array(
        'unique' => true
    ));
}
Parameters
string$columnName
array$validators
Returns
void

Definition at line 297 of file Abstract.php.

{
$this->_table->setColumnOptions($name, $options);
}
Doctrine_Record_Abstract::setListener (   $listener)
inherited

setListener

Parameters
Doctrine_EventListener_Interface | Doctrine_Overloadable$listener
Returns
Doctrine_Record

Definition at line 90 of file Abstract.php.

{
$this->_table->setRecordListener($listener);
return $this;
}
Doctrine_Locator_Injectable::setLocator ( Doctrine_Locator  $locator)
inherited

setLocator this method can be used for setting the locator object locally

Parameters
Doctrine_Locatorthe locator object
Returns
Doctrine_Locator_Injectable this instance

Definition at line 60 of file Injectable.php.

{
$this->_locator = $locator;
return $this;
}
Doctrine_Record_Generator::setOption (   $name,
  $value 
)
inherited

Sets given value to an option

Parameters
$optionthe name of the option to be changed
$valuethe value of the option
Returns
Doctrine_Plugin this object

Definition at line 104 of file Generator.php.

{
$this->_options[$name] = $value;
return $this;
}
Doctrine_Search::setTableDefinition ( )
inherited

buildDefinition

Returns
void

Definition at line 304 of file Search.php.

{
if ( ! isset($this->_options['table'])) {
throw new Doctrine_Record_Exception("Unknown option 'table'.");
}
$componentName = $this->_options['table']->getComponentName();
$className = $this->getOption('className');
$autoLoad = (bool) ($this->_options['generateFiles']);
if (class_exists($className, $autoLoad)) {
return false;
}
// move any columns currently in the primary key to the end
// So that 'keyword' is the first field in the table
$previousIdentifier = array();
foreach ($this->_table->getIdentifier() as $name) {
$previousIdentifier[$name] = $this->_table->getColumnDefinition($name);
$this->_table->removeColumn($name);
}
$columns = array('keyword' => array('type' => 'string',
'length' => 200,
'primary' => true,
),
'field' => array('type' => 'string',
'length' => 50,
'primary' => true),
'position' => array('type' => 'integer',
'length' => 8,
'primary' => true,
));
$this->hasColumns($columns);
$this->hasColumns($previousIdentifier);
}
Doctrine_Record_Abstract::unique (   $fields,
  $options = array(),
  $createUniqueIndex = true 
)
inherited

Defines a n-uple of fields that must be unique for every record.

This method Will automatically add UNIQUE index definition and validate the values on save. The UNIQUE index is not created in the database until you use

See Also
export().
Parameters
array$fieldsvalues are fieldnames
array$optionsarray of options for unique validator
bool$createUniqueIndexWhether or not to create a unique index in the database
Returns
void

Definition at line 128 of file Abstract.php.

{
return $this->_table->unique($fields, $options, $createUniqueIndex);
}
Doctrine_Search::updateIndex ( array  $data,
  $encoding = null 
)
inherited

updateIndex updates the index

Parameters
Doctrine_Record$record
Returns
integer

Definition at line 135 of file Search.php.

{
$this->initialize($this->_options['table']);
$fields = $this->getOption('fields');
$class = $this->getOption('className');
$name = $this->getOption('table')->getComponentName();
$conn = $this->getOption('table')->getConnection();
$identifier = $this->_options['table']->getIdentifier();
->createQuery()
->delete();
foreach ((array) $identifier as $id) {
$q->addWhere($id . ' = ?', array($data[$id]));
}
$q->execute();
if ($this->_options['batchUpdates'] === true) {
$index = new $class();
foreach ((array) $this->_options['table']->getIdentifier() as $id) {
$index->$id = $data[$id];
}
$index->save();
} else {
foreach ($fields as $field) {
$value = isset($data[$field]) ? $data[$field] : null;
$terms = $this->analyze($value, $encoding);
foreach ($terms as $pos => $term) {
$index = new $class();
$index->keyword = $term;
$index->position = $pos;
$index->field = $field;
foreach ((array) $this->_options['table']->getIdentifier() as $id) {
$index->$id = $data[$id];
}
$index->save();
$index->free(true);
}
}
}
}

Field Documentation

bool Doctrine_Record_Generator::$_initialized = false
protectedinherited

Whether or not the generator has been initialized

Definition at line 57 of file Generator.php.

Doctrine_Record_Abstract::$_table
protectedinherited
Parameters
Doctrine_Table$_tablereference to associated Doctrine_Table instance

Definition at line 38 of file Abstract.php.


The documentation for this class was generated from the following file: