/** * @deprecated */ static function _loadConfig($dictionary) { Ak::deprecateWarning('AkInflector::_loadConfig is deprecated and will be removed in future Akelos versions. Please use AkInflector::loadConfig() instead.'); return AkInflector::loadConfig($dictionary); }
public function _extractConditionsFromArgs($args, $options) { if (empty($args)) { $fetch = 'all'; } else { $fetch = $args[0]; } $num_args = count($args); // deprecated: acts like findFirstBySQL if ($num_args === 1 && !is_numeric($args[0]) && is_string($args[0]) && $args[0] != 'all' && $args[0] != 'first') { // $Users->find("last_name = 'Williams'"); => find('first',"last_name = 'Williams'"); Ak::deprecateWarning(array("AR::find('%sql') is ambiguous and therefore deprecated, use AR::find('first',%sql) instead", '%sql' => $args[0])); $options = array('conditions' => $args[0]); return array('first', $options); } //end // set fetch_mode to 'all' if none is given if (!is_numeric($fetch) && !is_array($fetch) && $fetch != 'all' && $fetch != 'first') { array_unshift($args, 'all'); $num_args = count($args); } if ($num_args > 1) { if (is_string($args[1])) { // $Users->find(:fetch_mode,"first_name = ?",'Tim'); $fetch = array_shift($args); $options = array_merge($options, array('conditions' => $args)); //TODO: merge_conditions } elseif (is_array($args[1])) { // $Users->find(:fetch_mode,array('first_name = ?,'Tim')); $fetch = array_shift($args); $options = array_merge($options, array('conditions' => $args[0])); //TODO: merge_conditions } } return array($fetch, $options); }
/** * Works like find_all, but requires a complete SQL string. Examples: * $Post->findBySql("SELECT p.*, c.author FROM posts p, comments c WHERE p.id = c.post_id"); * $Post->findBySql(array("SELECT * FROM posts WHERE author = ? AND created_on > ?", $author_id, $start_date)); */ function &findBySql($sql, $limit = null, $offset = null, $bindings = null, $returns = 'default', $simulation_class = 'AkActiveRecordMock') { if ($limit || $offset){ Ak::deprecateWarning("You're calling AR::findBySql with \$limit or \$offset parameters. This has been deprecated."); $this->_db->addLimitAndOffset($sql, array('limit'=>$limit,'offset'=>$offset)); } if(!isset($this->_activeRecordHasBeenInstantiated)){ return Ak::handleStaticCall(); } $objects = array(); $records = $this->_db->select ($sql,'selecting'); foreach ($records as $record){ if ($returns == 'default') { $objects[] =& $this->instantiate($this->getOnlyAvailableAttributes($record), false); } else if ($returns == 'simulated') { $objects[] = $this->_castAttributesFromDatabase($this->getOnlyAvailableAttributes($record),$this); } else if ($returns == 'array') { $objects[] = $this->_castAttributesFromDatabase($this->getOnlyAvailableAttributes($record),$this); } } if ($returns == 'simulated') { $false = false; $objects = $this->_generateStdClasses($simulation_class,$objects,$this->getType(),$false,$false,array('__owner'=>array('pk'=>$this->getPrimaryKey(),'class'=>$this->getType()))); } return $objects; }
/** * Works like find_all, but requires a complete SQL string. Examples: * $Post->findBySql("SELECT p.*, c.author FROM posts p, comments c WHERE p.id = c.post_id"); * $Post->findBySql(array("SELECT * FROM posts WHERE author = ? AND created_on > ?", $author_id, $start_date)); */ function &findBySql($sql, $limit = null, $offset = null, $bindings = null) { if ($limit || $offset) { Ak::deprecateWarning("You're calling AR::findBySql with \$limit or \$offset parameters. This has been deprecated."); $this->_db->addLimitAndOffset($sql, array('limit' => $limit, 'offset' => $offset)); } if (!isset($this->_activeRecordHasBeenInstantiated)) { return Ak::handleStaticCall(); } $objects = array(); $records = $this->_db->select($sql, 'selecting'); foreach ($records as $record) { $objects[] =& $this->instantiate($this->getOnlyAvailableAttributes($record), false); } return $objects; }
/** * Creates a new record with values matching those of the instance attributes. * Must be called as a result of a call to createOrUpdate. */ private function _create() { if (!$this->beforeCreate() || !$this->notifyObservers('beforeCreate')) { return $this->transactionFail(); } $this->_setRecordTimestamps(); // deprecated section if ($this->isLockingEnabled() && is_null($this->get('lock_version'))) { Ak::deprecateWarning(array("Column %lock_version_column should have a default setting. Assumed '1'.", '%lock_version_column' => 'lock_version')); $this->setAttribute('lock_version', 1); } // end $attributes = $this->getColumnsForAttributes($this->getAttributes()); foreach ($attributes as $column => $value) { $attributes[$column] = $this->castAttributeForDatabase($column, $value); } $pk = $this->getPrimaryKey(); $table = $this->getTableName(); $id = $this->_db->incrementsPrimaryKeyAutomatically() ? null : $this->_db->getNextSequenceValueFor($table); $attributes[$pk] = $id; $inserted_id = $this->_db->insertWithAttributes($table, $attributes, $pk, 'Create ' . $this->getModelName()); if ($this->transactionHasFailed()) { return false; } $this->setId($inserted_id); $this->_newRecord = false; if (!$this->afterCreate() || !$this->notifyObservers('afterCreate')) { return $this->transactionFail(); } return true; }
static function &call_user_func_array($function_name, $parameters) { Ak::deprecateWarning('Ak::call_user_func_array() is deprecated and will be removed from Akelos in future releases. Please use PHP\'s native call_user_func_array() function instead.'); $result = call_user_func_array($function_name, $parameters); return $result; }