本文整理汇总了PHP中AppModel::find方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::find方法的具体用法?PHP AppModel::find怎么用?PHP AppModel::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
public static function find($id)
{
$row = parent::find($id, UserModel::get_table_name());
$um = new UserModel($row["first_name"], $row["last_name"], $row["email"], $row["password"], $row["last_login"], $row["failed_login_attempts"], $row["date_created"]);
$um->id = $row["id"];
return $um;
}
示例2: find
public static function find($id)
{
$row = parent::find($id, PageModel::get_table_name());
$pm = new PageModel($row["page_text"], $row["adventure_id"], $row["image_url"], $row["date_created"]);
$pm->id = $row["id"];
return $pm;
}
示例3: refreshMirror
/**
*
* @param AppModel $model
*/
public function refreshMirror($model, $checkPendingOperations = false)
{
if ($checkPendingOperations) {
if ($this->_pending[$model->alias] > 0) {
return;
}
$this->_pending[$model->alias] = 0;
}
$config = $this->settings[$model->alias];
if ($model->Behaviors->enabled('Translate')) {
if ($config['findOptions']['recursive'] >= 0 || $model->Behaviors->Translate->settings[$model->alias]) {
$oldLang = SlConfigure::read('I18n.lang');
$locales = SlConfigure::read('I18n.locales');
$localesPreg = '/_' . implode('$|_', $locales) . '$/';
foreach ($locales as $lang => $locale) {
Sl::setLocale($lang);
$data = $model->find($config['findType'], $config['findOptions']);
if ($config['collectionField']) {
$this->_cleanup($config['name'], $locale);
}
$this->_write($config['name'], $this->_prepareData($model, $config, $data, $localesPreg), $locale);
}
Sl::setLocale($oldLang);
return;
}
}
$data = $model->find($config['findType'], $config['findOptions']);
if ($config['collectionField']) {
$this->_cleanup($config['name']);
}
$this->_write($config['name'], $this->_prepareData($model, $config, $data));
}
示例4: find
public function find($conditions = null, $fields = array(), $order = null, $recursive = null)
{
if (isset($this->userType) && $this->userType == 'admin') {
$this->contain("{$this->User->alias}.Hospital.code");
}
return parent::find($conditions, $fields, $order, $recursive);
}
示例5:
function __validateOneUser()
{
if (parent::find('count')) {
return false;
}
return true;
}
示例6: find
public function find($type = 'first', $queryData = array())
{
$catalog_field = 'backup_catalog';
$this->hasMany['Dataset']['conditions'][$catalog_field] = '1';
$queryData = array_merge_recursive(array('order' => array('Datachannel.ord' => 'asc'), 'limit' => 100), $queryData);
return parent::find($type, $queryData);
}
示例7: pingbackRegisterComment
/**
* Register pingback comment. Used by pingback server
*
* @param AppModel $model
* @param string $modelId
* @param array $options
* @param string $sourceUri
* @param string $targetUri
* @return boolean
*/
public function pingbackRegisterComment(&$model, $modelId, $sourceUri, $targetUri)
{
extract($this->settings[$model->alias]);
if ($model->{$commentAlias}->hasAny(array($commentAlias . '.foreign_key' => $modelId, 'author_url' => $sourceUri))) {
throw new XmlRpcResponseException(0, 'Pingback already registries in system.');
}
$sourceBody = $this->loadPageContent($sourceUri);
if (strpos($sourceBody, $targetUri) === false) {
throw new XmlRpcResponseException(0, 'Source link is not detected in target blog.');
}
$sourceBody = $this->cleanupPage($sourceBody);
$title = $this->fetchTitle($sourceBody);
$cite = $this->fetchPingbackCite($sourceBody, $sourceUri, $targetUri);
$isSpam = false;
$data = array('comment_type' => 'pingback', 'author_name' => $title . 'blog', 'author_url' => $sourceUri, 'title' => $title, 'foreign_key' => $modelId, 'model' => $model->alias, 'body' => $cite);
if ($model->{$commentAlias}->Behaviors->enabled('Antispamable')) {
$isSpam = $model->isSpam();
}
$data['is_spam'] = $isSpam ? 'spam' : 'clean';
$modelData = $model->find('first', array('conditions' => array('id' => $modelId), 'recursive' => -1));
if (!empty($modelData[$model->alias][$requireApproveModelField])) {
$data[$requireApproveCommentField] = 0;
}
$model->{$commentAlias}->create($data);
return $model->{$commentAlias}->save();
}
示例8: find
public static function find($id)
{
$row = parent::find($id, AdventureModel::get_table_name());
$am = new AdventureModel($row["title"], $row["user_id"], $row["date_created"]);
$am->id = $row["id"];
return $am;
}
示例9: find
function find($type = 'first', $queryData = array())
{
$this->belongsTo['Folder']['conditions']['Application.enabled'] = '1';
$fields = array('Application.id', 'Application.slug', 'Application.name', 'Application.plugin', 'Application.type', 'Application.home', 'Folder.id', 'Folder.slug', 'Folder.name', 'Application.folder_id');
$queryData = array_merge(array('fields' => $fields, 'order' => array(array('Application.ord' => 'asc')), 'limit' => 100, 'conditions' => array('Application.enabled' => '1')), $queryData);
return parent::find($type, $queryData);
}
示例10: find
public function find($type = 'first', $queryData = array())
{
if ($type == 'first' && (($alias = @$queryData['conditions']['Dataset.alias']) || ($alias = @$queryData['conditions']['Dataset.base_alias']))) {
App::import('model', 'MPCache');
$this->MPCache = new MPCache();
$output = $this->MPCache->getDataset($alias, @$queryData['full']);
if (!empty($output)) {
$output['orders'] = isset($output['orders_es']) ? $output['orders_es'] : array();
}
if (!empty($output['filters'])) {
foreach ($output['filters'] as &$f) {
if (strpos($f['filter']['field'], '.') === false) {
$f['filter']['field'] = $alias . '.' . $f['filter']['field'];
}
}
}
return $output;
}
$fields = array();
if (isset($queryData['fields'])) {
$fields = $queryData['fields'];
} else {
$fields = array('Dataset.id', 'Dataset.alias', 'Dataset.name', 'Dataset.class', 'Dataset.count', 'Dataset.channel_id', 'Dataset.default_sort', 'Datachannel.id', 'Datachannel.nazwa', 'Datachannel.slug', 'App.id', 'App.name', 'App.plugin', 'App.slug');
}
$queryData = array_merge_recursive(array('fields' => $fields, 'limit' => 100), $queryData);
return parent::find($type, $queryData);
}
示例11: find
/**
* Returns a result set array.
*
* Also used to perform new-notation finds, where the first argument is type of find operation to perform
* (sum / all / first / count / neighbors / list / threaded ),
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
* 'recursive', 'page', 'fields', 'offset', 'order')
*
* Eg:
* {{{
* find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'),
* 'fields' => array('name', 'email'),
* 'order' => 'field3 DESC',
* 'recursive' => 2,
* 'group' => 'type'
* ));
* }}}
*
* Specifying 'fields' for new-notation 'list':
*
* - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value.
* - If a single field is specified, 'id' is used for key and specified field is used for value.
* - If three fields are specified, they are used (in order) for key, value and group.
* - Otherwise, first and second fields are used for key and value.
*
* @param array $conditions SQL conditions array, or type of find operation (all / first / count / neighbors / list / threaded)
* @param mixed $fields Either a single string of a field name, or an array of field names, or options for matching
* @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of records
* @access public
* @link http://book.cakephp.org/view/449/find
*/
function find($conditions = null, $fields = array(), $order = null, $recursive = null)
{
if (!empty($conditions)) {
$conditions = strtolower($conditions);
if ($conditions == 'sum') {
$campoAMeter = array('sum("FondosLineasDeAccion"."monto") AS "FondosLineasDeAccion__sum"');
if (is_array($fields)) {
if (!empty($fields['fields'])) {
$fields['fields'] = Set::merge($fields['fields'], $campoAMeter);
} else {
$fields['fields'] = $campoAMeter;
}
if (!empty($fields['group'])) {
$fields['fields'] = Set::merge($fields['fields'], $fields['group']);
}
} elseif (is_string($fields)) {
return parent::find($conditions, $fields, $order, $recursive);
}
$trajo = parent::find('all', $fields, $order, $recursive);
if (count($trajo) > 1) {
return $trajo;
} else {
return $trajo[0]['FondosLineasDeAccion']['sum'];
}
}
}
return parent::find($conditions, $fields, $order, $recursive);
}
示例12: find
public static function find($id)
{
$row = parent::find($id, QuestionModel::get_table_name());
$qm = new QuestionModel($row["page_id"], $row["q_and_a"], $row["date_created"]);
$qm->id = $row["id"];
return $qm;
}
示例13: main
function main()
{
if (empty($this->args)) {
return $this->err('Usage: ./cake fixturize <table>');
}
if ($this->args[0] == '?') {
return $this->out('Usage: ./cake fixturize <table> [-force] [-reindex]');
}
$options = array('force' => false, 'reindex' => false);
foreach ($this->params as $key => $val) {
foreach ($options as $name => $option) {
if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
$options[$name] = true;
}
}
}
foreach ($this->args as $table) {
$name = Inflector::classify($table);
$Model = new AppModel(array('name' => $name, 'table' => $table));
$file = sprintf('%stests/fixtures/%s_fixture.php', APP, Inflector::underscore($name));
$File = new File($file);
if ($File->exists() && !$options['force']) {
$this->err(sprintf('File %s already exists, use --force option.', $file));
continue;
}
$records = $Model->find('all');
$out = array();
$out[] = '<?php';
$out[] = '';
$out[] = sprintf('class %sFixture extends CakeTestFixture {', $name);
$out[] = sprintf(' var $name = \'%s\';', $name);
$out[] = ' var $records = array(';
$File->write(join("\n", $out));
foreach ($records as $record) {
$out = array();
$out[] = ' array(';
if ($options['reindex']) {
foreach (array('old_id', 'vendor_id') as $field) {
if ($Model->hasField($field)) {
$record[$name][$field] = $record[$name]['id'];
break;
}
}
$record[$name]['id'] = String::uuid();
}
foreach ($record[$name] as $field => $val) {
$out[] = sprintf(' \'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
}
$out[] = ' ),';
$File->write(join("\n", $out));
}
$out = array();
$out[] = ' );';
$out[] = '}';
$out[] = '';
$out[] = '?>';
$File->write(join("\n", $out));
$this->out(sprintf('-> Create %sFixture with %d records (%d bytes) in "%s"', $name, count($records), $File->size(), $file));
}
}
示例14: main
function main()
{
if (empty($this->args)) {
return $this->err('Usage: ./cake uuidize <table>');
}
if ($this->args[0] == '?') {
return $this->out('Usage: ./cake uuidize <table> [-force] [-reindex]');
}
$options = array('force' => false, 'reindex' => false);
foreach ($this->params as $key => $val) {
foreach ($options as $name => $option) {
if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
$options[$name] = true;
}
}
}
foreach ($this->args as $table) {
$name = Inflector::classify($table);
$Model = new AppModel(array('name' => $name, 'table' => $table));
$records = $Model->find('all');
foreach ($records as $record) {
$Model->updateAll(array('id' => '"' . String::uuid() . '"'), array('id' => $record[$name]['id']));
}
}
}
示例15: find
function find($type = 'first', $options = array())
{
if (isset($options['hideSecret']) && $options['hideSecret'] == true) {
$options['conditions'] = am(@$options['conditions'], array('AND' => array("LOCATE('s', SUBSTRING_INDEX(Channel.defmodes, ' ', 1))" => 0, "LOCATE('p', SUBSTRING_INDEX(Channel.defmodes, ' ', 1))" => 0)));
}
unset($options['hideSecret']);
return parent::find($type, $options);
}