本文整理汇总了PHP中ActiveRecord::has_field_for_class方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::has_field_for_class方法的具体用法?PHP ActiveRecord::has_field_for_class怎么用?PHP ActiveRecord::has_field_for_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::has_field_for_class方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testActiveRecordFunctioning
public function testActiveRecordFunctioning()
{
//OK FUNZIONA
$this->assertTrue(ActiveRecord::has_table_for_class("Simple2"));
$this->assertTrue(ActiveRecord::get_table_for_class("Simple2"), "simple2_table");
//NON FUNZIONA
$this->assertEqual(count(ActiveRecord::getPrimaryKeyFields("Simple2")), 1);
$pk_fields = ActiveRecord::getPrimaryKeyFields("Simple2");
$this->assertEqual($pk_fields[0], "id");
//NON FUNZIONA
$this->assertTrue(ActiveRecord::has_field_for_class("Simple2", "id"));
$this->assertTrue(ActiveRecord::has_field_for_class("Simple2", "nome"));
$this->assertTrue(ActiveRecord::has_field_for_class("Simple2", "livello"));
$this->assertTrue(ActiveRecord::has_field_for_class("Simple2", "properties"));
$this->assertTrue(ActiveRecord::has_field_for_class("Simple2", "working"));
}
示例2: testCreateSaveDelete
public function testCreateSaveDelete()
{
$this->assertTrue(ActiveRecord::has_field_for_class("Simple", "id"));
$peer = new SimplePeer();
$do = $peer->new_do();
$do->id = 1;
$do->nome = "Paolino Paperino";
$do->livello = 16;
$peer = new SimplePeer();
$objects = $peer->find_all();
$this->assertEqual(count($objects), 0);
$peer->save($do);
$objects = $peer->find_all();
$this->assertEqual(count($objects), 1);
$ob = $objects[0];
$this->assertEqual($ob->id, 1);
$this->assertEqual($ob->nome, "Paolino Paperino");
$this->assertEqual($ob->livello, 16);
$peer->delete_by_id(1);
$objects = $peer->find_all();
$this->assertEqual(count($objects), 0);
}
示例3: __find_all_by__
public function __find_all_by__($method, $args)
{
$original_method = $method;
$method = str_replace("find_all_by_", "", $method);
$field_list = explode("_AND_", $method);
if (count($args) != count($field_list)) {
Log::error(__METHOD__, "Il numero dei campi non corrisponde : {$original_method}");
}
$table = $this->__getMyTable();
$raw_class_name = $this->__getRawClassName();
$ss = DB::newSelect($table);
$i = 0;
foreach ($field_list as $field) {
if (!ActiveRecord::has_field_for_class($raw_class_name, $field)) {
throw new Exception("Il campo '{$field}' non e' presente nella tabella '{$table}', raw class name " . $raw_class_name . " :" . ActiveRecord::print_fields_for_class($raw_class_name) . " - " . ActiveRecord::print_tables());
}
$ss->addConditionEquals($field, $args[$i]);
$i++;
}
return $this->__load_into_objects($ss);
}